摘要: ###方式一:自然排序(java.lang.Comparable) 概述: 1:Comparable接口强行对实现它的每个类的对象进行整体排序。这种排序被称为类的自然排序。 2:实现 Comparable 的类必须实现 compareTo(Object obj) 方法,两个对象即 通过 compar 阅读全文
posted @ 2021-04-16 19:02 袁中 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 总结: 增:append(xxx) 删:delete(int start,int end) 改:setCharAt(int n,char ch) /replace(int start,int end,String str) 查:charAt(int n) 插:insert(int offset,xx 阅读全文
posted @ 2021-04-16 18:20 袁中 阅读(35) 评论(0) 推荐(0) 编辑
摘要: ###1.String与基本数据类型,包装类之间的转换 String->基本数据类型,包装类 :调用包装类的静态方法:parsexxx(str) 基本数据类型,包装类 →String:调用String重载的valueof(xxx) String s1="123"; //String-->Intege 阅读全文
posted @ 2021-04-16 17:26 袁中 阅读(49) 评论(0) 推荐(0) 编辑
摘要: ###1:String的两种实例化的方式 方式一:通过字面量定义的方试 方式二:通过new+构造器的方式 //此时s1和s2的数据JAVAEE声明在方法区中的字符串常量池中。 String s1="JAVAEE"; String s2="JAVAEE"; //通过new+构造器的方试:此时的s3和s 阅读全文
posted @ 2021-04-16 16:19 袁中 阅读(137) 评论(0) 推荐(0) 编辑
摘要: ###1.案例:两个打印机交替打印 class Communication implements Runnable{ private int i=1; // private final ReentrantLock lock=new ReentrantLock(); @Override public 阅读全文
posted @ 2021-04-16 16:01 袁中 阅读(33) 评论(0) 推荐(0) 编辑
摘要: ###方法1:同步代码块 synchronized ( 对象){ // 需要被同步的代码; } class Window extends Thread{ // private int ticket=100;//这样会有300张票 private static int ticket=100;//只有1 阅读全文
posted @ 2021-04-16 15:41 袁中 阅读(132) 评论(0) 推荐(0) 编辑
摘要: ###JDK1.5之前创建新执行线程有两种方法: 方式1:继承Thread类 : 1) 定义子类继承Thread类。 2) 子类中重写Thread类中的run方法。 3) 创建Thread子类对象,即创建了线程对象。 4) 调用线程对象start方法:启动线程,调用run方法。 //1.创建一个继承 阅读全文
posted @ 2021-04-16 14:50 袁中 阅读(86) 评论(0) 推荐(0) 编辑