Results 1 to 2 of 2
  1. #1
    darek9576 is offline Member
    Join Date
    Mar 2010
    Rep Power

    Default Converting to String

    String class provides us with the method String.valueOf(some stuff) that basically converts "some stuff" into a string..
    But we can also concatenate "some stuff" with an empty String ("").
    Both these methods result in a String representation of an object(or other data type) so my question is what is the difference between the two, advantages of one over the other, disadvantages of one over the other and which method do you guys usually use when forced to convert something to a String and why??

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    The API documentation of valueOf() describes what it does: but note that there are various versions that take different argument types.

    String concatenation/conversion is dealt with in the JLS 15.18.1.

    If this is a homework question your best bet is to read what these things actually do, then decide and express your own ideas and preferences for comment.

Similar Threads

  1. Is it OK to do this... (converting int to string)
    By Psyclone in forum New To Java
    Replies: 1
    Last Post: 02-16-2010, 06:51 PM
  2. Converting a String into a array.
    By taraxgoesxboom in forum New To Java
    Replies: 12
    Last Post: 02-22-2009, 06:29 AM
  3. Converting object to string
    By Preethi in forum New To Java
    Replies: 4
    Last Post: 06-14-2008, 04:29 AM
  4. Converting String to Double
    By srini in forum New To Java
    Replies: 1
    Last Post: 12-24-2007, 09:03 PM
  5. Converting Epoch to string Date
    By amyedwards in forum New To Java
    Replies: 3
    Last Post: 12-14-2007, 11:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts