alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (string-reverse.scala)

This example Scala source code file (string-reverse.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

array, les, les, list, mis, mise\u0301rables, stringbuilder, stringbuilder, strings, test, test, unit, utf-8, utf-8

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

 

new blog posts

 

Copyright 1998-2021 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.