-
Notifications
You must be signed in to change notification settings - Fork 1
/
HackEarthMain
76 lines (61 loc) · 2.67 KB
/
HackEarthMain
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* IMPORTANT: Multiple classes and nested static classes are supported */
/*
* uncomment this if you want to read input.
*/
//imports for BufferedReader
import java.io.BufferedReader;
import java.io.InputStreamReader;
//import for Scanner and other utility classes
import java.util.*;
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
class TestClass {
public static void main(String args[] ) throws Exception {
List<String> inputList = new ArrayList<>();
String firstname = null;
List<String> address = new ArrayList<>();
List<String> children = new ArrayList<>();
StringTokenizer tk = null;
//BufferedReader
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = null; // Reading input from STDIN
while((input = br.readLine()) != null){
inputList.add(input);//add input line by line into a list
}
System.out.println("*************** Printing List Items Starts ********************");
inputList.stream().forEach(row ->{
System.out.println("Name:>>"+row);
});
System.out.println("***************List Item Ends **********************************");
//print entire list
System.out.println("Entire List Object:>"+inputList);
System.out.println("********************Data Extraction Begins *********************************************");
try{
//get first Name here
if(inputList.get(0) != null){
firstname = inputList.get(0);
System.out.println("FNAme:*:*:"+firstname);
}
//get Second Address List
if(inputList.get(1) != null){
//String Tokenizer and save the results in the List
tk = new StringTokenizer(inputList.get(1),"");
//check is token exists
while(tk.hasMoreTokens()){
address.add(tk.nextToken());
}
System.out.println("Address List:"+address);
}
//children List
if(inputList.get(2) != null){
tk = new StringTokenizer(inputList.get(2),"");
//get list of children fro string
while(tk.hasMoreTokens()){
children.add(tk.nextToken());
}
System.out.println("Children List::>>"+children);
}
}catch(Exception e){
System.out.println(e);
}
}
}