Java String valueOf() method example.

Java 8Object Oriented ProgrammingProgramming

The valueOf() method in Java of the String class accepts a character as a parameter and returns the string representation of the char argument.

Example

 Live Demo

import java.lang.*;
public class StringDemo {
   public static void main(String[] args) {
      String str1 = String.valueOf('k');
      String str2 = String.valueOf('m');
     
      //Print the string representation of char
      System.out.println(str1);
      System.out.println(str2);
   }
}

Output

k
m
raja
Published on 12-Feb-2018 10:05:54
Advertisements