Results 1 to 2 of 2
  1. #1
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default Quick Question regarding converting char to String

    This may sound stupid, but is there any difference between a declared String object and one that is created using the String.valueOf(char) method?

    Example:
    Java Code:
         char c = 'L';
         String fromChar = String.valueOf(c);
    
         String notFromChar = "L";
    Is there any difference between the fromChar and the notFromChar variables? If you compare them to each other using the .equals() method, it does return true, but I've run across a Third Party jar that processes differently depending on what I pass it.

    Any help/thoughts would be appreciated.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,800
    Rep Power
    25

    Default Re: Quick Question regarding converting char to String

    If the equals() method returns true then the contents of the two Strings is the same.

    No idea what the third party code does without seeing the code.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 6
    Last Post: 02-17-2011, 02:22 PM
  2. check a string char by char
    By Sotsiak in forum New To Java
    Replies: 2
    Last Post: 10-23-2010, 10:24 PM
  3. Converting double to char array?
    By Blasz in forum New To Java
    Replies: 9
    Last Post: 08-29-2010, 08:32 PM
  4. Converting a char to an int
    By michail in forum New To Java
    Replies: 10
    Last Post: 01-06-2010, 10:09 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
  •