Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Java Program to split a string with dot
Let’s say the following is our string.
String str = "Java is a programming language. James Gosling developed it.";
We will now see how to split a string using the split() method. Include the delimiter as the parameter.
String[] strSplit = str.split("\.");
Above, we have split the string with dot as you can see under the split methods parameter.
The following is an example.
Example
public class Demo {
public static void main(String[] args) {
String str = "Java is a programming language. James Gosling developed it.";
System.out.println("String: "+str);
String[] strSplit = str.split("\.");
System.out.println("Splitting String...");
for (int i = 0; i < strSplit.length; i++)
System.out.println(strSplit[i]);
}
}
Output
String: Java is a programming language. James Gosling developed it. Splitting String... Java is a programming language James Gosling developed it
Advertisements
