Search Java Programs

Wednesday, January 20, 2010

Java String toCharArray Example

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
* @version 16-May-2008
* @author Rose India Team
*/



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

Website Design by Mayuri Multimedia