top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between toString() and valueOf() in Java?

+2 votes
192 views
What is the difference between toString() and valueOf() in Java?
posted Sep 24, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Object.toString() is used for objects.
String.valueOf(primitive) for primitives.
String.valueOf(object) returns "null" if the object is null else object.toString()

answer Sep 25, 2014 by Arun Gowda
...