Monday, 7 May 2012

Java String toCharArray Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
String class toCharArray method example.

String class toCharArray method example:- This example demonstrates the working of toCharArray method. 
this method converts complete String value in to a char array type value.

Syntax:- toCharArray() 


Here is the code:-
/**
 * @(#) ToCharArrayString.java 
 * ToCharArrayString class demonstrates the working of toCharArray() method of String class of lang package
 */


public class ToCharArrayString {
  public static void main(String args[]) {
    //method converts complete String value to char array type value  
    String str = " einstein relativity concept is still a concept of great discussion";
    char heram[] = str.toCharArray();
    // complete String str value is been converted in to char array data by
    // the method
    System.out.print("Converted value from String to char array is:  ");
    System.out.println(heram);
  }
}
Output of the program:-
-----------------------
Converted value from String to char array is:   einstein relativity concept is still a concept of great discussion

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...