摘要: public class Test { private String name; public Test(String name) { // name=name;//这个时候就近访问了,方法里面有,外面就不会访问了!这个时候打印为空 this.name=name; } public void speak() { ... 阅读全文
posted @ 2018-10-27 10:12 sunnybowen 阅读(815) 评论(0) 推荐(0) 编辑
摘要: public class Test { private int age; //构造方法不能有void,方法名必须和类名相同,构造方法不能返回值,可以有一个单独的return public Test(int a) { age = a; //System.out.println(age); } public void speak... 阅读全文
posted @ 2018-10-27 10:09 sunnybowen 阅读(241) 评论(0) 推荐(0) 编辑
摘要: public class Break { public static void main(String[] args) { int[][] arr = new int[3][]; arr[0] = new int[]{11, 12}; arr[1] = new int[]{1, 2, 3}; arr[2] = new i... 阅读全文
posted @ 2018-10-27 10:07 sunnybowen 阅读(97) 评论(0) 推荐(0) 编辑
摘要: public class Break { public static void main(String[] args) { int i,j; STOP: for(i=1;i4) { //break; 如果只是简单的break,只是跳出了内层循环,外层循环还在执行,会打印换行符 ... 阅读全文
posted @ 2018-10-27 09:54 sunnybowen 阅读(142) 评论(0) 推荐(0) 编辑
摘要: package com.bowen.dong; /** * * @author bw * */ public class Example005 { public static void main(String[] args) throws Exception { char a[] = new char[26]; for(int i=0;i<26;i++) ... 阅读全文
posted @ 2018-10-27 09:47 sunnybowen 阅读(2966) 评论(0) 推荐(0) 编辑
摘要: public class Test { //下面的方法会在垃圾回收前调用(对象被回收前) /** * 这个方法是重写了这个方法,系统本来就有的,垃圾被回收,方法就会被调用,这个方法会在垃圾被回收前调用 */ public void finalize() { System.out.println("对象即将被回收"); } } ... 阅读全文
posted @ 2018-10-27 09:44 sunnybowen 阅读(102) 评论(0) 推荐(0) 编辑
摘要: package com.bowen.dong; import java.io.File; /** * * @author bw * @version1.0 */ public class FileTest { public static void main(String[] args) { // TODO Auto-generated method stub... 阅读全文
posted @ 2018-10-27 09:38 sunnybowen 阅读(103) 评论(0) 推荐(0) 编辑
摘要: package com.bowen.dong; /** * 1 String类的基本操作 * 获取长度 public int length(); * public char charAt(int index); * public int indexOf(char a); * public int lastIndexOf(char a); *... 阅读全文
posted @ 2018-10-27 09:35 sunnybowen 阅读(163) 评论(0) 推荐(0) 编辑
摘要: final修饰的方法不能被重写,是最终方法 final修饰的类的类是最终类,不能被继承! Final修饰变量,一次赋值,终身不变 被final关键字修饰的成员变量 必须赋初值!!!局部变量先定义,再赋初值。 阅读全文
posted @ 2018-10-27 09:32 sunnybowen 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 不要把按位或与异或运算符搞混了!!! 阅读全文
posted @ 2018-10-27 09:28 sunnybowen 阅读(421) 评论(0) 推荐(0) 编辑