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. Internal implementationSignatureThe signature or syntax of string valueOf() method is given below: Returnsstring representation of given value Java String valueOf() method exampleTest it NowOutput: 3010 Java String valueOf(boolean bol) Method ExampleThis is a boolean version of overloaded valueOf() method. It takes boolean value and returns a string. Let's see an example. Test it NowOutput: true false Java String valueOf(char ch) Method ExampleThis is a char version of overloaded valueOf() method. It takes char value and returns a string. Let's see an example. Test it NowOutput: A B Java String valueOf(float f) and valueOf(double d)This is a float version of overloaded valueOf() method. It takes float value and returns a string. Let's see an example. Test it NowOutput: 10.05 10.02 Java String valueOf() Complete ExamplesLet's see an example where we are converting all primitives and objects into strings. Test it NowOutput: true 11 12 13 14 15.5 16.5 java [email protected]
Next TopicJava Regex
|