-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsplit.java
More file actions
54 lines (34 loc) · 712 Bytes
/
split.java
File metadata and controls
54 lines (34 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.*;
public class split{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the String : ");
String str = sc.nextLine();
String[] strArr = str.split(" ", 2);
for(String s:strArr)
{
System.out.println(s);
}
String[] strArr1 = str.split(" ", 3);
for(String s:strArr1)
{
System.out.println(s);
}
String[] strArr2 = str.split(" ", -3);
for(String s:strArr2)
{
System.out.println(s);
}
String[] strArr3 = str.split(" ", 0);
for(String s:strArr3)
{
System.out.println(s);
}
String abc = "hi@for@oyu";
String[] strArr4 = abc.split("@", 3);
for(String s:strArr4)
{
System.out.println(s);
}
}
}