java 类型转换
1. String 转 int
1 String str= "111"; 2 3 4 //1. 5 Integer.parseInt(str); 6 7 //2. 8 Integer.valueOf(str).intValue();
2. String 转 Long
1 String str = "11111111111111" 2 3 //1. 4 Long.parseLong(str) 5 6 //2. 7 Long.valueOf(str)
3.int 转 String
1 int i = 111; 2 3 //1. 4 String str = "" + i; 5 6 //2. 7 String str = String.valueOf(i);
4.long 转 int
1 long i = 11111; 2 3 //1. 4 int ii = (int)i; 5 6 //2. 7 int ii= new Long(i).intValue();
5. 左移 、右移
1 int i = 111; 2 3 //左移2位 4 i << 2; 5 6 //右移移2位 7 i << 2;
6.取模
1 int i = 111; 2 3 //取模 4 int i1 = i % 2;
参考:https://blog.csdn.net/qq_40817827/article/details/89422868