上交作业啦

来源:3-6 自由编程

慕虎1394068

2020-08-09 06:26:06

package com.company.thread;

class Letter implements Runnable {

    char[] letter = new char[26];

    public Letter(){
        int i=0;
        for (char j = 'a'; j<='z'; j++) {
            letter[i] = j;
            i++;
        }
    }

    public void run() {
        for (char ch:letter) {
            System.out.print(ch+" ");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class Main {

    public static void main(String[] args) {
   // write your code here
        Letter l=new Letter();
        Thread t=new Thread (l);
        t.start();
    }
}


写回答

1回答

好帮手慕阿慧

2020-08-09

同学你好,练习题完成的不错,很棒,继续加油!祝学习愉快~

0

0 学习 · 16556 问题

查看课程