-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChainInspection.java
More file actions
32 lines (29 loc) · 901 Bytes
/
Copy pathChainInspection.java
File metadata and controls
32 lines (29 loc) · 901 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
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class ChainInspection {
public static void main(String[] args) {
String input = "4-2;BEGIN-3;3-4;2-END";
String[] tempArr = input.split(";");
for(int i=0;i<tempArr.length;i++)
System.out.print(tempArr[i] + " ");
System.out.println();
Map<String,String> map = new HashMap<String,String>();
for(String s: tempArr) {
String[] elements = s.split("-");
map.put(elements[0], elements[1]);
/*for(int i=0;i<elements.length;i++)
System.out.print(elements[i]+"");*/
/*if(elements[0].equals(elements[1]))
System.out.println("bad");*/
}
System.out.println(map.entrySet());
for(Entry<String, String> s: map.entrySet()) {
if(s.getKey().equals(s.getValue()))
System.out.println("bad");
else if(map.get("BEGIN") != null) {
System.out.println(map.get("BEGIN"));
}
}
}
}