Skip to content

Commit 7ea319e

Browse files
author
xiachaochao
committed
123
1 parent 6e5c523 commit 7ea319e

28 files changed

Lines changed: 158 additions & 215 deletions

JavaBase/out.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
1*1=1
2+
2*1=2 2*2=4
3+
3*1=3 3*2=6 3*3=9
4+
4*1=4 4*2=8 4*3=12 4*4=16
5+
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
6+
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
7+
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
8+
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
9+
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81

JavaBase/src/com/xinan/enum1/Enum1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public int getAge() {
3131
return age;
3232
}
3333

34-
public String setAge(int age) {
34+
public void setAge(int age) {
3535
this.age = age;
36-
return "修改年龄";
36+
/*return "修改年龄";*/
3737
}
3838

3939
public boolean isRest() {

JavaBase/src/com/xinan/enum1/Enum1Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static void main(String[] args) {
99
Enum1.TUE.isRest();
1010
//System.out.println(Enum1.MON.valueOf("3"));
1111
System.out.println(Enum1.TUE.getAge());
12-
System.out.println(Enum1.TUE.setAge(20));
12+
Enum1.TUE.setAge(20);
1313
System.out.println(Enum1.TUE.getAge());//???????????????
1414
}
1515
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.xinan.generics;
2+
3+
public class Person<T> {
4+
private String name;
5+
private T pass;
6+
7+
public Person() {
8+
super();
9+
}
10+
11+
public Person(String name, T pass) {
12+
super();
13+
this.name = name;
14+
this.pass = pass;
15+
}
16+
17+
public String getName() {
18+
return name;
19+
}
20+
21+
public void setName(String name) {
22+
this.name = name;
23+
}
24+
25+
public T getPass() {
26+
return pass;
27+
}
28+
29+
public void setPass(T pass) {
30+
this.pass = pass;
31+
}
32+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.xinan.generics;
2+
3+
public class TestPerson {
4+
5+
public static void main(String[] args) {
6+
Person<String> person1=new Person<String>();
7+
person1.setPass("hellomoto");
8+
System.out.println(person1.getPass());
9+
10+
Person<Integer> person2=new Person<Integer>();
11+
person2.setPass(2222);
12+
System.out.println(person2.getPass());
13+
14+
}
15+
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.xinan.test02;
2+
/*四、上机试题:
3+
打印乘法口诀表到文件中。
4+
要求:
5+
A.创建一个普通类,类里有一个普通的方法,打印乘法口诀表的方法;
6+
B.在另一个测试类中,创建一个实现Runnable接口的线程;
7+
C.在run()方法中,使用反射唤醒打印乘法口诀表的方法;
8+
D.启动线程,打印乘法口诀表到文件中!*/
9+
10+
import java.io.File;
11+
import java.io.FileOutputStream;
12+
import java.io.IOException;
13+
import java.io.PrintStream;
14+
15+
public class Multiplication {
16+
public static void multiplict() throws IOException {// 乘法口诀表的打印
17+
PrintStream printStream = new PrintStream("D:\\乘法口诀表.txt");
18+
for (int i = 1; i < 10; i++) {
19+
for (int j = 1; j <= i; j++) {
20+
printStream.print(j + "*" + i + "=" + i * j + " ");
21+
}
22+
printStream.println(" ");
23+
}
24+
}
25+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.xinan.test02;
2+
3+
import java.io.File;
4+
import java.io.FileOutputStream;
5+
import java.io.IOException;
6+
import java.io.PrintStream;
7+
import java.lang.reflect.InvocationTargetException;
8+
import java.lang.reflect.Method;
9+
10+
//创建线程的实现类
11+
public class TestDemo implements Runnable {
12+
public static void main(String[] args) throws Exception {
13+
14+
/*
15+
* FileReader fReader = new FileReader(System.in); FileWriter fWriter =
16+
* new FileWriter("乘法口诀表.txt");
17+
*
18+
* BufferedReader bReader = new BufferedReader(fReader); BufferedWriter
19+
* bWriter = new BufferedWriter(fWriter);
20+
*
21+
* String s = bReader.readLine(); while (s != null) { bWriter.write(s);
22+
* bWriter.newLine(); s = bReader.readLine(); }
23+
*
24+
* bReader.close(); bWriter.close();
25+
*/
26+
Thread thread = new Thread(new TestDemo());// 通过实现runnanble接口创建线程
27+
thread.start();
28+
29+
}
30+
31+
@Override
32+
public void run() {
33+
try {
34+
reflect01();
35+
} catch (IllegalArgumentException e) {
36+
// TODO Auto-generated catch block
37+
e.printStackTrace();
38+
} catch (InvocationTargetException e) {
39+
// TODO Auto-generated catch block
40+
e.printStackTrace();
41+
} catch (Exception e) {
42+
// TODO Auto-generated catch block
43+
e.printStackTrace();
44+
}
45+
46+
}
47+
48+
public static void reflect01() throws Exception {
49+
Class<?> clazz = Multiplication.class;// 通过反射获取类
50+
Method method = clazz.getMethod("multiplict");
51+
Object obj = clazz.newInstance();
52+
method.invoke(obj);
53+
}
54+
55+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.xinan.test02;
2+
3+
public class TestDemo01 {
4+
public static void main(String[] args) {
5+
Thread thread = new Thread(new TestDemo());// 通过实现runnanble接口创建线程
6+
thread.start();
7+
}
8+
}

JavaBase/三角形.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
打印结束
2+
1*1=1
3+
2*1=2 2*2=4
4+
3*1=3 3*2=6 3*3=9
5+
4*1=4 4*2=8 4*3=12 4*4=16
6+
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
7+
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
8+
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
9+
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
10+
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81

JavaBase/乘法口诀表.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)