|
Scala example source code file (string-reverse.scala)
The Scala string-reverse.scala source code
/** In case we ever feel like taking on unicode string reversal.
* See ticket #2565.
*/
object Test {
val xs = "Les Mise\u0301rables" // this is the tricky one to reverse
val ys = "Les Misérables"
val xs2 = new StringBuilder(xs)
val ys2 = new StringBuilder(ys)
def main(args: Array[String]): Unit = {
val out = new java.io.PrintStream(System.out, true, "UTF-8")
out.println("Strings")
List(xs, xs.reverse, ys, ys.reverse) foreach (out println _)
out.println("StringBuilder")
out.println(xs2.toString)
out.println(xs2.reverseContents().toString)
out.println(ys2.toString)
out.println(ys2.reverseContents().toString)
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala string-reverse.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.