summaryrefslogtreecommitdiff
path: root/src/test/java/Test.java
blob: 0ba1f8b9f1fff89ad54decfc4f1715748cc385e3 (plain)
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
public class Test {

    public static String intToIp(int ip) {
        StringBuilder sb = new StringBuilder();
        int num = 0;
        boolean needPoint = false; // 是否需要加入'.'
        for (int i = 0; i < 4; i++) {
            if (needPoint) {
                sb.append('.');
            }
            needPoint = true;
            int offset = 8 * (3 - i);
            num = (ip >> offset) & 0xff;
            sb.append(num);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        People people = new People();
        if (2>1){
            people.setAge(2);
        }
        System.out.println(people.getAge());
    }
}