-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringDemo.java
More file actions
60 lines (47 loc) · 1.3 KB
/
Copy pathStringDemo.java
File metadata and controls
60 lines (47 loc) · 1.3 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 string;
class MyNumbers {
Integer i;
String s;
public MyNumbers(Integer i, String s) {
this.i = i;
this.s = s;
}
/*
* @Override public int compareTo(MyNumbers o) { if (this.i < o.i) { return
* -1; } else return 1; }
*/
@Override
public String toString() {
return "MyNumbers [i=" + i + ", s=" + s + "]";
}
}
public class StringDemo {
public static void main(String[] args) {
String s = "sams";
long count = s.chars().filter(i -> i == 's').count();
System.out.println(count);
/*
* Comparator<MyNumbers> com = new Comparator<MyNumbers>() {
*
* @Override public int compare(MyNumbers o1, MyNumbers o2) { { if (o1.i
* < o2.i) { return -1; } else return 1; } } }; List<MyNumbers> ls = new
* ArrayList<>(); ls.add(new MyNumbers(10, "hey")); ls.add(new
* MyNumbers(5, "hello")); ls.add(new MyNumbers(18, "woow"));
* Collections.sort(ls, com); System.out.println(ls);
*/
/*
* String str = "a"; String a = "ab";
* System.out.println(str.compareTo(a));
*/
// INt
// Collections.sort(list);
/*
* System.out.println(System.identityHashCode(a));
*
* System.out.println(System.identityHashCode(str)); String st = new
* String("hey"); System.out.println(System.identityHashCode(st));
*
* System.out.println(str == st.intern());
*/
}
}