split method in java
// Java program to demonstrate working of split(regex,
// limit) with small limit.
public class GFG {
public static void main(String args[])
{
String str = "geekss@for@geekss";
String[] arrOfStr = str.split("@", 2);
for (String a : arrOfStr)
System.out.println(a);
}
} String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
String part2 = parts[1]; // 034556
public class SplitExample2 {
public static void main(String args[])
{
String str = "My name is Chaitanya";
//regular expression is a whitespace here
String[] arr = str.split(" ");
for (String s : arr)
System.out.println(s);
}
}
Also in Java:
- java load image
- main class java
- java nextpermutation
- java if a or b
- take a value from keyboard java
- arraylist remove method java
- java using .indexof to fin a space
- how to add element to arraylist
- working with buttons in applet java
- biginteger in java
- how to fill a 2d array in java
- diagonal difference hackerrank solution in java 8 using list
- priority queue java reverse order
- java map foreach
- java hashmap put
- how do I change the opacity of a JButton
- function in java
- hide element selenium
- java hello world
- convert from integer to character java
- java stream find specific element
- iterate trough linked list java
- how to print in java
- split method in java