-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
34 lines (28 loc) · 909 Bytes
/
Rectangle.java
File metadata and controls
34 lines (28 loc) · 909 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
33
34
package Generics;
import java.util.ArrayList;
import java.util.HashMap;
public class Rectangle <T extends Number >{
private final Pair<T,T> topLeft;
private final Pair<T,T> bottomRight;
public Rectangle(T top, T left, T bottom,T right){
this.topLeft=new Pair<>(top,left);
this.bottomRight=new Pair<>(bottom,right);
}
public static String getArray(ArrayList<String> strings){
String res="";
for(String s:strings){
if(s.split(" ").length==1){
res+=","+s;
}
}return res;
}
public static HashMap<Character, Integer> freqCount(String s){
HashMap<Character, Integer> mapping = new HashMap<>();
for (int i=0;i<s.length();i++){
char c = s.charAt(i);
mapping.putIfAbsent(c,0);
mapping.put(c,mapping.get(c)+1);
}
return mapping;
}
}