// Program to explain the following String function :
// static String valueOf( double num )class MvalueOf
{
public static void main( String args[ ] )
{
char ch[ ] = { 'J', 'A', 'V', 'A' };
String s1 = String.valueOf( ch );
System.out.println( " String 1 : " + s1 );String s2 = String.valueOf( "Java Programming Examples." );
System.out.println( " String 2 : " + s2 );String s3 = String.valueOf( true );
System.out.println( " String 3 : " + s3 );String s4 = String.valueOf( new char[ ] { 'J', 'A', 'V', 'A' }, 2, 2 );
System.out.println( " String 4 : " + s4 );String s5 = String.valueOf( 100 );
System.out.println( " String 5 : " + s5 );String s6 = String.valueOf( 55.55d );
System.out.println( " String 6 : " + s6 );String s7 = String.valueOf( 55.55f );
System.out.println( " String 7 : " + s7 );String s8 = String.valueOf( 100l );
System.out.println( " String 8 : " + s8 );String s9 = String.valueOf( Math.PI );
System.out.println( " String 9 : " + s9 );
}
}
Output:String 1 : JAVA
String 2 : Java Programming Examples.
String 3 : true
String 4 : VA
String 5 : 100
String 6 : 55.55
String 7 : 55.55
String 8 : 100
String 9 : 3.141592653589793