随笔分类 -  java基础

摘要:Comparable<T> Comparable 定义在 Person类的内部: public class Person implements Comparable<Person> { @Override public int compareTo(Person o) { // 返回负整数、 0、正整 阅读全文
posted @ 2016-03-08 22:44 rhythm of the rain 阅读(101) 评论(0) 推荐(0)
摘要:一、继承关系 Throwable 类 |--Error 类 是系统不可恢复的错误,JVM发生的错误 | |--OutOfMemoryError 堆内存溢出 | |--StackOverflowError 栈内存溢出 |--Exception 类 程序可以检查处理的异常,常见的异常继承根 |--jav 阅读全文
posted @ 2016-02-29 11:12 rhythm of the rain 阅读(176) 评论(0) 推荐(0)
摘要:一.简介 1.java中常用的日期有三种(精确到毫秒):A.long--毫秒数B.Date--日期C.Calendar--日历、抽象类 2.Java中日期经常使用以下五个方面:A.创建日期B.日期格式化显示C.日期的转换(主要是和字符串之间的相互转换)D.日期中年.月.日.时.分.秒.星期.月份等获 阅读全文
posted @ 2016-02-17 17:23 rhythm of the rain 阅读(977) 评论(0) 推荐(1)
摘要:1.判断字符串中是否含有另一字符串 2.截取字符串 3.与int类型转换 String:不可变长字符串, 因此每次改变String类型的时候,都会创建一个新的 String 对象;如果内存里存在则不开辟新的内存空间 Stringbuffer:可变长字符串,线程安全,可作为全局变量使用 StringB 阅读全文
posted @ 2015-02-03 21:16 rhythm of the rain 阅读(265) 评论(0) 推荐(0)
摘要:1.所有的类都继承Object类,Object中有一个getClass()方法,因此所有的对象都能有调用getClass()方法。 2.Class是什么? 类在被load到内存后,其实也是一个对象,如abc.class就是一个Class的对象,每个对象都可以调用getClass()方法来获得这个对象 阅读全文
posted @ 2014-03-20 19:59 rhythm of the rain 阅读(181) 评论(0) 推荐(0)
摘要:静态方法: String与其他数据类型之间的转换: int → String: String s = String.valueOf(int i) Stirng → int: int i = Integer.parseInt( s ); 方法: 1.string.trim()---去掉两端空格 2.s 阅读全文
posted @ 2014-03-19 19:50 rhythm of the rain 阅读(388) 评论(0) 推荐(0)
摘要:1.static(用static修饰的方法或属性属于类,属于对象) 修饰属性:属于类而不属于对象,存在内存中的数据区,多个对象共享此属性。注意在继承的时候,父类中的static属性子类也共享。 修饰方法:可以由类直接调用,不用new对象。 修饰语句块:在classloader加载类的时候执行(new 阅读全文
posted @ 2014-03-19 15:26 rhythm of the rain 阅读(130) 评论(0) 推荐(0)