上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 31 下一页
摘要: 使用throws声明的方法表示此方法不处理异常,而是交给方法的调用处进行处理; public class Math { public int div(int i,int j)throws Exception{ System.out.println("********计算开始********"); i 阅读全文
posted @ 2020-07-28 10:48 一块 阅读(170) 评论(0) 推荐(0) 编辑
摘要: public class Demo07 { public static void main(String[] args) { final Printer p = new Printer(); new Thread() { public void run() { while (true) { p.pr 阅读全文
posted @ 2020-07-22 21:34 一块 阅读(155) 评论(0) 推荐(0) 编辑
摘要: public class Demo06 { public static void main(String[] args) { Thread t1 = new Thread() { public void run() { for (int i = 0; i < 10; i++) { System.ou 阅读全文
posted @ 2020-07-22 21:05 一块 阅读(831) 评论(0) 推荐(0) 编辑
摘要: join(); 当前线程暂停,等待指定的线程执行结束后,当前线程在继续。 join(int); 可以等待指定的毫秒之后继续。 public class Demo05 { public static void main(String[] args) { Thread t1 = new Thread() 阅读全文
posted @ 2020-07-22 20:49 一块 阅读(156) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { Thread t1 = new Thread() { public void run() { for (int i = 0; i < 2; i++) { System.out.println(getName() + " 阅读全文
posted @ 2020-07-22 20:36 一块 阅读(139) 评论(0) 推荐(0) 编辑
摘要: public class Demo03 { public static void main(String[] args) throws InterruptedException { Test01(); new Thread(){ public void run(){ for(int i = 0;i< 阅读全文
posted @ 2020-07-20 21:45 一块 阅读(137) 评论(0) 推荐(0) 编辑
摘要: public class Demo02 { public static void main(String[] args) { Test01(); new Thread(){ public void run(){ System.out.println(getName()+".......ccccccc 阅读全文
posted @ 2020-07-20 21:30 一块 阅读(1124) 评论(0) 推荐(0) 编辑
摘要: public class Demo02 { public static void main(String[] args) {第一种方法: new Thread("构造方法设置线程名字"){ public void run(){ System.out.println(this.getName()+". 阅读全文
posted @ 2020-07-20 21:03 一块 阅读(730) 评论(0) 推荐(0) 编辑
摘要: public class Demo01 { public static void main(String[] args) {//方法一: new Thread() { //1.继承Thread类 public void run() { //2.重写run方法 for (int i = 0; i < 阅读全文
posted @ 2020-07-20 20:47 一块 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 多态性在面向对象中是一个最重要的概念,在java中面向对象主要有一下两种主要体现: 1.方法的重载和重写。 2.对象的多态性。 对象的多态性主要分为以下两种类型。 1.向上转型:子类对象 > 父类对象 2.向下转型 父类对象 >子类对象 对于向上转型,程序会自动完成,而对于向下转型时,必须要明确的指 阅读全文
posted @ 2020-07-18 15:45 一块 阅读(209) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 31 下一页