- 博客(4)
- 资源 (2)
- 问答 (3)
- 收藏
- 关注
原创 JAVA学习笔记(三)模板设计模式(抽象类)
abstract class Action{ public static final int EAT = 1; public static final int SLEEP = 5; public static final int WORK = 10; public void command(int flag){ switch(flag){ case EAT: this.e...
2018-04-13 15:44:11
88
原创 String(二)(JAVA学习笔记)
字符串一旦定义不可改变:字符串的底层实现实际上就是数组,如下为String的jdk源码:public final class String implements java.io.Serializable, Comparable<String>, CharSequence{ /** The value is used for character storage. */...
2018-04-11 18:53:46
99
原创 String的两种实例化方式比较(JAVA学习笔记)
字符串共享产生问题:String str = new String("hello");该字符串常量并没有保存在常量池中,可以使用String的intern()方法进行解决String str = new String("hello").intern();所以String对象的两种实例化方式的区别:(1)直接赋值,直接开辟一块堆内存空间,并且该字符串对象可以保存在对象池中,供下次使用;(2)构造方法...
2018-04-11 18:22:05
235
原创 String类(一)
字符串常量本质上就是String类的匿名对象example:public class testDemo{ public static void main(String args[]){ String str = "hello"; System.out.println("hello".equals(str)); }}字符串“hello”可以调用equals()方法,说明它为Str...
2018-04-11 16:51:28
117
TA创建的收藏夹 TA关注的收藏夹
TA关注的人