-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaskMiddle.java
More file actions
58 lines (33 loc) · 1.07 KB
/
MaskMiddle.java
File metadata and controls
58 lines (33 loc) · 1.07 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
package LogicalPrograms;
public class MaskMiddle {
public static String muskcard(String str) {
if(str.length() < 4) {
return str;
}
else {
// Hide front value
String res = "";
for(int i=0;i<str.length();i++) {
if( i < str.length()-4) {
res += "#";
}
}
res += str.substring(str.length()-4);
// print middle values hide
// res = str.substring(0,str.length()-10);
//res += "####";
//res += str.substring(10,str.length());
// res = str.substring(0,str.length()-4); //print last values hide
// res +="####";
return res;
}
}
public static void main(String[] args) {
// MaskMiddle m = new MaskMiddle("4556364607935616");
System.out.println(MaskMiddle.muskcard("1478128816325010"));
System.out.println(MaskMiddle.muskcard("4556364607935616"));
System.out.println(MaskMiddle.muskcard("64607935616"));
System.out.println(MaskMiddle.muskcard("1"));
System.out.println(MaskMiddle.muskcard(""));
}
}