
java日常
清流Cyl
个人主页 filwc.cn
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
ArrayIndexOutOfBoundsException-数组越界问题
1.int []a = new int[10]; a.length = 10,a的最大下标为9 在进行循环输出时,循环控制部分应为i<a.length 2.int []a = new int[10]; int []b = new int[10]; if(i<L.length&&j<R.length&&L[i]<=R...原创 2018-04-15 11:10:02 · 8718 阅读 · 0 评论 -
java-工厂模式示例
interface Service{ void method1(); void method2(); } interface ServiceFactory{ Service getService(); } class Implementation1 implements Service{ Implementation1() { // TODO...转载 2018-07-27 10:37:06 · 431 阅读 · 0 评论 -
Java 中到底是应该用接口类型 还是实现类的类类型去引用对象?
eg //implA 为接口 ClassB为其实现类 implA A=new ClassB();//接口类型的引用变量A 去接收对象地址 or ClassB A=new ClassB();//类类型的引用变量A 去接收对象地址 完整文章 :https://blog.youkuaiyun.com/summerxiachen/article/details/79733800 文章中提到的工厂模式示例:h...转载 2018-07-27 10:21:32 · 555 阅读 · 0 评论 -
java--内部类中.this与.new用法
.this 生成对外部类的引用 public class DotThis { void f(){ System.out.println("DotThis.f()"); } public class Inner{ public DotThis outer(){ return DotThis.this; ...原创 2018-07-27 09:23:07 · 6429 阅读 · 0 评论 -
java--在构造函数中调用其他构造函数
使用 this 关键字 public class Flower { int petalCount = 0; String s = "cyl is qingliu"; Flower(int petals){ System.out.println("int"); petalCount = petals; } Flow...原创 2018-07-25 09:34:43 · 19765 阅读 · 0 评论 -
java-标签的使用
public class Test { public static void main(String[] args) { int sum =0; label1: for(int i = 0;i<5;i++){ for(int j = 0; j< 2;j++){ ...原创 2018-06-26 11:49:53 · 204 阅读 · 0 评论 -
Arrays类-java
1.位置:java,util.Arrays2.Arrays.fill(i, 47); 用数字47将数组i填充3.System.arraycopy(i, 0, j, 0, i.length); 将i中o-i.len的内容复制到j4.Arrays.equals(i, j) 比较两个数组是否相等5.Arrays.deepEquals() 比较多维数...原创 2018-05-24 10:52:08 · 270 阅读 · 0 评论 -
java-Class对象
1.F xxx= new F();//F为一个类 2.Class f = Class.forName("F")//返回对F类的引用 3.类字面常量:Class f = F.class//更加安全的操作,类在编译时就会被检查,同时可应用于接口,数组以及基本数据类型,该方法不会自动的初始化该class对象 4.泛化的Class引用:Class <?> x = intClass//可与...原创 2018-05-14 16:23:02 · 172 阅读 · 0 评论 -
java-容器
1.容器的划分*Connection *List *ArrayList//随机访问元素较快,但在中间插入元素与删除元素时较慢 *LinkedList//与ArrayList相反 *set//不保存相同元素 ...原创 2018-05-06 15:44:21 · 139 阅读 · 0 评论 -
java常见报错
1.ArrayIndexOutOfBoundsException数组越界 2. ArithmeticException除零错误原创 2018-04-15 11:11:06 · 1422 阅读 · 0 评论 -
java---迭代器
目录 Iterator ListIterator Iterator(单向移动) 创建: List<?> list = new ArrayList<?>(); Iterator <?> it = list.iterator(); 判断容器中是否还有元素: it.hasNext(); 获取元素: it.next(); 移除元素:(在...原创 2018-07-28 09:36:56 · 236 阅读 · 0 评论