This is a Java Program to Illustrate Use of getChar() and split() Method.
Here we divide the given string into array of strings depending upon the positions of blank spaces. Also we use getChar() method to get characters from given given string.
Here is the source code of the Java Program to Illustrate Use of getChar() and split() Method. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Split_getChar
{
public static void main(String args[])
{
String[] a;
String b = "Sanfoundary 1000 Java Programs";
a = b.split(" ");
for (int i = 0; i < a.length; i++)
{
System.out.println(a[i]);
}
System.out.println("Using getChar() method:");
char c[]=new char[11];
b.getChars(0, 11, c, 0);
for(int i=0;i<11;i++)
{
System.out.print(c[i]);
}
}
}
Output:
$ javac Split_getChar.java $ java Split_getChar Sanfoundary 1000 Java Programs Usin getChar() method: Sanfoundary
Sanfoundry Global Education & Learning Series – 1000 Java Programs.
advertisement
advertisement
Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.
Related Posts:
- Practice BCA MCQs
- Practice Programming MCQs
- Check Java Books
- Check Programming Books
- Apply for Computer Science Internship