onlinecode

Converting char to string in Java

Converting char to string in Java

In this post we will give you information about Converting char to string in Java. Hear we will give you detail about Converting char to string in JavaAnd how to use it also give you demo for it if it is necessary.

In java we can use the String.valueOf() method to convert a char to string.

Here is an example that converts char p to a string.

public class Main{   public static void main(String[] args) {         char ok='p';         String str = String.valueOf(ok);         System.out.println(str);  }}

Output:

p

Similarly, you can use the string concatenation.

public class Main{   public static void main(String[] args) {         char ok='p';         String str = ""+ok;         System.out.println(str);  }}

Hope this code and post will helped you for implement Converting char to string in Java. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version