About 56,200 results
Open links in new tab
  1. How to use the toString method in Java? - Stack Overflow

    Sep 1, 2010 · Can anybody explain to me the concept of the toString() method, defined in the Object class? How is it used, and what is its purpose?

  2. java - when to use toString () method - Stack Overflow

    Apr 13, 2016 · 1 You can use toString () on an class by overriding it to provide some meaningful text representation of your object. For example you may override toString () on a Person class …

  3. How to override toString() properly in Java? - Stack Overflow

    May 24, 2012 · Java toString () method If you want to represent any object as a string, toString () method comes into existence. The toString () method returns the string representation of the …

  4. What exactly is the purpose of a toString() method in Java?

    Aug 29, 2020 · I recently used a toString() method in one of my projects to organize the output in my console but I was wondering if there is any significance to this method rather than it simply …

  5. what is the use of toString () in java - Stack Overflow

    May 22, 2010 · As the javadoc says: Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a …

  6. java - Using Enum values as String literals - Stack Overflow

    Jul 12, 2011 · JavaDoc: String java.lang.Enum.name () Returns the name of this enum constant, exactly as declared in its enum declaration. Most programmers should use the toString …

  7. Java enum - why use toString instead of name - Stack Overflow

    Mar 17, 2017 · Most programmers should use the toString method in preference to this one, as the toString method may return a more user-friendly name. This method is designed primarily …

  8. Java - Convert integer to string - Stack Overflow

    579 This question already has answers here: Java int to String - Integer.toString (i) vs new Integer (i).toString () (11 answers) How do I convert from int to String? (21 answers)

  9. How to convert an int array to String with toString method in Java

    Jun 6, 2012 · public static String toString(int[] a) Returns a string representation of the contents of the specified array. The string representation consists of a list of the array's elements, …

  10. java - Why should I use Integer.toString () instead of just printing ...

    Jan 2, 2013 · int k = 5; System.out.println("The number is " + k); Is there a good reason to use the toString() method for non-string data types? And in my specific example, are there any int …