上一页 1 ··· 8 9 10 11 12 13 下一页
摘要: //线程创建方式三:实现callable接口/*callable的好处1、可以定义返回值2、可以抛出异常 */public class TestCallable implements Callable<Boolean> { private String url;//网络图片地址 private St 阅读全文
posted @ 2021-11-27 14:41 tuyin 阅读(94) 评论(0) 推荐(0)
摘要: //创建线程方式一:继承Thread类,重写run()方法,调用start开启线程//总结:线程开启不一定立即执行,由CPU调度执行public class TestThread1 extends Thread { @Override public void run() { //run方法线程体 f 阅读全文
posted @ 2021-11-27 14:08 tuyin 阅读(114) 评论(0) 推荐(0)
摘要: package com.thread;//模拟龟兔赛跑public class Race implements Runnable { //胜利者 private static String winner; //实现Runnable接口,重写run方法 @Override public void ru 阅读全文
posted @ 2021-11-27 13:57 tuyin 阅读(65) 评论(0) 推荐(0)
摘要: package com.tu.oop.demo8;//abstract 抽象类:类 extends:单继承~ (接口可以多继承)public abstract class Action { //约束~有人帮我们实现~ //abstract,抽象方法,只有方法名字,没有方法的实现! public ab 阅读全文
posted @ 2021-11-21 17:14 tuyin 阅读(50) 评论(0) 推荐(0)
摘要: package com.tu.oop.demo7;//staticpublic class Student { private static int age;//静态的变量 private double score;//非静态的变量 public void run(){ } public stati 阅读全文
posted @ 2021-11-21 16:39 tuyin 阅读(42) 评论(0) 推荐(0)
摘要: package com.tu.oop.demo6;public class Person { public void run(){ System.out.println("Person类执行了!!!"); }}/* //一个对象的实际类型是确定的 //new Student(); //new Per 阅读全文
posted @ 2021-11-21 16:36 tuyin 阅读(55) 评论(0) 推荐(0)
摘要: super注意点: 1、super调用父类的构造方法,必须在构造方法的第一行! 2、super必须只能出现在子类的方法或者构造方法中! 3、super和this不能同时调用构造方法!VS this: 代表的对象不同: this:本身调用者的这个对象 super:代表父类对象的引用 前提 this:没 阅读全文
posted @ 2021-11-21 16:32 tuyin 阅读(48) 评论(0) 推荐(0)
摘要: package com.tu.oop.demo2;//java > classpublic class Person { //一个类即使什么都不写,它也会存在一个方法 //显示的定义构造器 //1、必须和类的名字相同 //2、必须没有返回类型,也不能写void String name; int ag 阅读全文
posted @ 2021-11-17 21:38 tuyin 阅读(48) 评论(0) 推荐(0)
摘要: public class Demo3 { public static void main(String[] args) { //非静态方法调用,类实例化之后才存在,所以应该在new之后再调用 //实际参数和形式参数的类型要对应 int add = new Demo3().add(2, 3); //静 阅读全文
posted @ 2021-11-17 17:46 tuyin 阅读(86) 评论(0) 推荐(0)
摘要: //值传递public class Demo4 { public static void main(String[] args) { int a = 1; System.out.println(a);//1(输出结果) Demo4.change(a); System.out.println(a);/ 阅读全文
posted @ 2021-11-17 17:23 tuyin 阅读(60) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 下一页