怎么打印数字时候会显示正方形???那里错了?怎么修改?
时间:2011-12-13
来源:互联网
public class MyThread implements Runnable {
private char n;
private int time;
private char i;
public MyThread(char n, int time) {
this.n = n;
this.time = time;
}
public void run() {
if (n == '1') {
for (char i = 1; i <= 26; i++) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(" " + i);
}
}
else if (n == 'A') {
for (char i = 'A'; i <= 'Z'; i++) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(" " + i);
}
} else {
for (char i = 'a'; i <= 'z'; i++) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(" " + i);
}
}
}
public static void main(String[] args) {
MyThread t1 = new MyThread('A', 1000);
Thread t = new Thread(t1);
t.start();
MyThread t2 = new MyThread('a', 2000);
Thread tt = new Thread(t2);
tt.start();
MyThread t3 = new MyThread('1', 3000);
Thread ttt = new Thread(t3);
ttt.start();
}
}
private char n;
private int time;
private char i;
public MyThread(char n, int time) {
this.n = n;
this.time = time;
}
public void run() {
if (n == '1') {
for (char i = 1; i <= 26; i++) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(" " + i);
}
}
else if (n == 'A') {
for (char i = 'A'; i <= 'Z'; i++) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(" " + i);
}
} else {
for (char i = 'a'; i <= 'z'; i++) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(" " + i);
}
}
}
public static void main(String[] args) {
MyThread t1 = new MyThread('A', 1000);
Thread t = new Thread(t1);
t.start();
MyThread t2 = new MyThread('a', 2000);
Thread tt = new Thread(t2);
tt.start();
MyThread t3 = new MyThread('1', 3000);
Thread ttt = new Thread(t3);
ttt.start();
}
}
作者: mc519677263 发布时间: 2011-12-13
if (n == '1') {
for (char i = 1; i <= 26; i++) {
===>
if (n == '1') {
for (int i = 1; i <= 26; i++) {
for (char i = 1; i <= 26; i++) {
===>
if (n == '1') {
for (int i = 1; i <= 26; i++) {
作者: huntor 发布时间: 2011-12-13
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28