0
class Random {

}
object Random extends App{

  val randomObj = new Random
  val strObj = new String("Akash")

  println("Output :- "+randomObj +" - String := "+ strObj)
}

How do i Print the reference of String like it print with class

  • What do you mean exactly? Do you want to print your strings like 'java.util.Random@2cac3000'? – codejitsu Jun 27 '16 at 12:12
  • Possible duplicate of [How do you get the "object reference" of an object in java when toString() and hashCode() have been overridden?](http://stackoverflow.com/questions/580984/how-do-you-get-the-object-reference-of-an-object-in-java-when-tostring-and-h) – Dima Jun 27 '16 at 13:11

0 Answers0