Spilit the String into Small fraction
| Previous | Home | Next |
Following program for spilit the string into small fraction.
/*
* Save as a SpilitString.java
* Progrma for Split the String into the Element.
*/
package r4r.co.in;
import java.io.*;
public class SpilitString {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your String:" + "");
String string = reader.readLine();
//Code for Split of String
int i;
/*
* Create a StringArray and fill With element
*/
String[] temp = string.split(" ");
for (i = 0; i < temp.length; i++) {
System.out.println(i + " Element in Spilit String is: " + temp[i]);
}
System.out.println("Total Element in String: " + i);
}
}
Enter your String:
hey! i'm working with R4R Tech Soft0 Element in Spilit String is: hey!
1 Element in Spilit String is: i'm
2 Element in Spilit String is: working
3 Element in Spilit String is: with
4 Element in Spilit String is: R4R
5 Element in Spilit String is: Tech
6 Element in Spilit String is: Soft
Total Element in String: 7
| Previous | Home | Next |