Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Convert String to char example

  1. /*
  2.  * Convert String to char example. Program to convert String
  3.  * to char.
  4.  */
  5.  
  6. public class StringToChar {
  7.  
  8.  public static void main(String args[]){
  9.  
  10.   String strCh = "h";
  11.    
  12.   //to convert String to char use charAt method of String class.
  13.   char ch = strCh.charAt(0);
  14.  
  15.   System.out.println("String converted to char: " + ch);
  16.  
  17.  }
  18.  
  19. }
No votes yet
Share this

Post new comment

4 + 11 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.