-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamsApp.java
More file actions
60 lines (42 loc) · 1.57 KB
/
StreamsApp.java
File metadata and controls
60 lines (42 loc) · 1.57 KB
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
package rider;
import java.math.BigInteger;
import java.util.Arrays;
public class StreamsApp {
public static void main(String[] args) {
//List<Integer> list = Arrays.asList(8,4,5);
//Map<String, TreeMap<Integer, String>> map = new HashMap();
// streams once created can be only used once and will throw an exception if we try to use it again
// stream is already used or consumed...
/*list.stream().
filter(n -> n%2 == 1).
map(n-> n * 2).
sorted().
forEach(n -> System.out.println(n));
int result = list.parallelStream().
map(n -> n * 2).
reduce(0, (c,e) -> c + e);
System.out.println("result::" + result);*/
/*if((int)Math.log10(number+1)!=(int)Math.log10(number)) {
System.out.println("All 9s");
System.out.println("Next Palidrome for the number "+ number +" is: "+(number+2));
return;
}*/
System.out.println("99999::" + ( (int) Math.log10(999) + 1));
System.out.println("100000:" + ( (int) Math.log10(1000) + 1));
System.out.println("10::"+ (int) (Math.random() * 11));
char a = 1;
char b = 2;
int a1 = (int) a;
int b1 = (int) b;
System.out.println("result::" + Integer.valueOf(a).equals(Integer.valueOf(b)));
String s = "123";
String[] str = s.split("");
System.out.println("1::" + Arrays.toString(str));
int[] numberArr = new int[s.length()];
for (int i =0; i <= s.length() -1 ; i++) {
System.out.println("i::" + i + "::" + str[i]);
numberArr[i] = Integer.valueOf(str[i]);
}
System.out.println("2::" + Arrays.toString(numberArr));
}
}