Java Program Function valueOf() Example

This java code will give the value of a string using function valueOf(). In the given example this function gives the value of ‘no’ and ‘d’.
.
class ValueOfDemo
{
public static void main(String args [])
{
String str;

int no=5;
str=String.valueOf(no);
System.out.println(no);

double d=3.456;
str=String.valueOf(d);
System.out.println(d);
}
}

Add Comment