Skip to content

Commit c722fb7

Browse files
committed
格式化代码
1 parent cb5cc68 commit c722fb7

4 files changed

Lines changed: 102 additions & 103 deletions

File tree

src/main/java/basic/BitTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package basic;
22

33
/**
4-
* Created by yangqc on 2017/5/3.
4+
* @author yangqc
5+
* @date 2017/5/3
56
*/
67
public class BitTest {
78

8-
public static void main(String[] args) {
9-
System.out.println((1 << 14) - 1);
10-
}
9+
public static void main(String[] args) {
10+
System.out.println((1 << 14) - 1);
11+
}
1112
}

src/main/java/basic/TestInteger.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
*/
88
public class TestInteger {
99

10-
public static void main(String[] args) {
11-
Integer a = 1;
12-
Integer b = 2;
13-
Integer c = 3;
14-
Integer d = 3;
15-
Integer e = 321;
16-
Integer f = 321;
17-
Long g = 3L;
10+
public static void main(String[] args) {
11+
Integer a = 1;
12+
Integer b = 2;
13+
Integer c = 3;
14+
Integer d = 3;
15+
Integer e = 321;
16+
Integer f = 321;
17+
Long g = 3L;
1818

19-
System.out.println(c == d);
20-
System.out.println(e == f);
21-
System.out.println(c == (a + b));
22-
System.out.println(c.equals(a + b));
23-
System.out.println(g == (a + b)); //����
24-
System.out.println(g.equals(a + b));
25-
}
19+
System.out.println(c == d);
20+
System.out.println(e == f);
21+
System.out.println(c == (a + b));
22+
System.out.println(c.equals(a + b));
23+
System.out.println(g == (a + b)); //����
24+
System.out.println(g.equals(a + b));
25+
}
2626
}
Lines changed: 79 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package datastructure;
22

3-
import java.io.FileInputStream;
4-
import java.io.FileOutputStream;
5-
import java.io.IOException;
6-
import java.io.ObjectInputStream;
7-
import java.io.ObjectOutputStream;
8-
import java.io.Serializable;
3+
import java.io.*;
94
import java.util.ArrayList;
105
import java.util.List;
116

@@ -14,92 +9,92 @@
149
*/
1510
public class IndexTree {
1611

17-
static private int Sn = -1;
18-
static private Node root;
12+
static private int Sn = -1;
13+
static private Node root;
1914

20-
static private class Node implements Serializable {
15+
static private class Node implements Serializable {
2116

22-
int data;
23-
transient Node left;
24-
transient Node right;
25-
int l = -1, r = -1;
17+
int data;
18+
transient Node left;
19+
transient Node right;
20+
int l = -1, r = -1;
2621

27-
public Node(int data, Node l, Node r) {
28-
this.data = data;
29-
this.left = l;
30-
this.right = r;
31-
}
22+
public Node(int data, Node l, Node r) {
23+
this.data = data;
24+
this.left = l;
25+
this.right = r;
26+
}
3227

33-
public int write(ObjectOutputStream out) throws IOException {
34-
if (left != null) {
35-
l = left.write(out);
36-
}
37-
if (right != null) {
38-
r = right.write(out);
39-
}
40-
Sn++;
41-
out.writeObject(this);
42-
return Sn;
43-
}
28+
public int write(ObjectOutputStream out) throws IOException {
29+
if (left != null) {
30+
l = left.write(out);
31+
}
32+
if (right != null) {
33+
r = right.write(out);
34+
}
35+
Sn++;
36+
out.writeObject(this);
37+
return Sn;
38+
}
4439

45-
private void init(List<Node> list) {
46-
if (l != -1) {
47-
left = list.get(l);
48-
left.init(list);
49-
}
50-
if (r != -1) {
51-
right = list.get(r);
52-
right.init(list);
53-
}
54-
}
40+
private void init(List<Node> list) {
41+
if (l != -1) {
42+
left = list.get(l);
43+
left.init(list);
44+
}
45+
if (r != -1) {
46+
right = list.get(r);
47+
right.init(list);
48+
}
49+
}
5550

56-
@Override
57-
public String toString() {
58-
StringBuilder sb = new StringBuilder();
59-
sb.append(data + " ");
60-
if (left != null) {
61-
sb.append(left);
62-
}
63-
if (right != null) {
64-
sb.append(right);
65-
}
66-
return sb.toString();
51+
@Override
52+
public String toString() {
53+
StringBuilder sb = new StringBuilder();
54+
sb.append(data + " ");
55+
if (left != null) {
56+
sb.append(left);
57+
}
58+
if (right != null) {
59+
sb.append(right);
60+
}
61+
return sb.toString();
62+
}
6763
}
68-
}
6964

70-
static public void read(ObjectInputStream in) {
71-
List<Node> list = new ArrayList<>();
72-
Node n;
73-
try {
74-
while (((n = (Node) in.readObject()) != null)) {
75-
list.add(n);
76-
}
77-
} catch (Exception e) {
78-
e.printStackTrace();
65+
static public void read(ObjectInputStream in) {
66+
List<Node> list = new ArrayList<>();
67+
Node n;
68+
try {
69+
while (((n = (Node) in.readObject()) != null)) {
70+
list.add(n);
71+
}
72+
} catch (Exception e) {
73+
e.printStackTrace();
74+
}
75+
root = list.get(list.size() - 1);
76+
root.init(list);
7977
}
80-
root = list.get(list.size() - 1);
81-
root.init(list);
82-
}
8378

84-
public static void main(String[] args) throws IOException {
85-
// 构造一棵二叉树
86-
/*
87-
* 1 2 3 4 5 6
88-
*/
89-
Node n6 = new Node(6, null, null);
90-
Node n4 = new Node(4, n6, null);
91-
Node n5 = new Node(5, null, null);
92-
Node n2 = new Node(2, n4, n5);
93-
Node n3 = new Node(3, null, null);
94-
Node n1 = new Node(1, n2, n3);
95-
root = n1;
96-
System.out.println(root);
97-
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("abc.ser"));
98-
root.write(out);
99-
out.close();
100-
ObjectInputStream in = new ObjectInputStream(new FileInputStream("abc.ser"));
101-
read(in);
102-
in.close();
103-
System.out.println(root);
104-
}
79+
public static void main(String[] args) throws IOException {
80+
// 构造一棵二叉树
81+
/*
82+
* 1 2 3 4 5 6
83+
*/
84+
Node n6 = new Node(6, null, null);
85+
Node n4 = new Node(4, n6, null);
86+
Node n5 = new Node(5, null, null);
87+
Node n2 = new Node(2, n4, n5);
88+
Node n3 = new Node(3, null, null);
89+
Node n1 = new Node(1, n2, n3);
90+
root = n1;
91+
System.out.println(root);
92+
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("abc.ser"));
93+
root.write(out);
94+
out.close();
95+
ObjectInputStream in = new ObjectInputStream(new FileInputStream("abc.ser"));
96+
read(in);
97+
in.close();
98+
System.out.println(root);
99+
}
105100
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package jvm.classloader;
22

3+
/**
4+
* @author yangqc
5+
*/
36
public class TestClass {
47

58
}

0 commit comments

Comments
 (0)