-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestPropellante1.java
More file actions
32 lines (27 loc) · 903 Bytes
/
TestPropellante1.java
File metadata and controls
32 lines (27 loc) · 903 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
package com.gokul.matrix;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;
public class TestPropellante1 {
public static void main(String[] args) {
String str = "I'm coming out raw... my game is beyond pain.. game is life ";
Set<String> set = new LinkedHashSet<>();
ArrayList<String> list = new ArrayList<String>();
for (String s : str.split(" ")) {
list.add(s);
set.add(s);
}
System.out.println("Total number of words in the sentence are " + str.split(" ").length);
System.out.println("Total number of Duplicate words in the sentence are " + (str.split(" ").length - set.size()));
System.out.println("sentence after removal");
for (String s : set) {
System.out.print(s + " ");
list.remove(s);
}
System.out.println("");
System.out.println("Duplicate Words are");
for (String s : list) {
System.out.print(s + " ");
}
}
}