Saturday, 12 September 2015

Java String valueOf

Java String valueOf

The java string valueOf() method converts different types of values into string. By the help of string valueOf() method, you can convert int to string, long to string, boolean to string, character to string, float to string, double to string, object to string and char array to string.

Signature

The signature or syntax of string valueOf() method is given below:
  1. public static String valueOf(boolean b)  
  2. public static String valueOf(char c)  
  3. public static String valueOf(char[] c)  
  4. public static String valueOf(int i)  
  5. public static String valueOf(long l)  
  6. public static String valueOf(float f)  
  7. public static String valueOf(double d)  
  8. public static String valueOf(Object o)  

Returns

string representation of given value

Java String valueOf() method example

  1. public class StringValueOfExample{  
  2. public static void main(String args[]){  
  3. int value=30;  
  4. String s1=String.valueOf(value);  
  5. System.out.println(s1+10);//concatenating string with 10  
  6. }}  
Output:
3010

No comments:

Post a Comment