摘要: 内部类访问规则内部类可以直接访问外部类中的成员,包括私有。访问格式:外部类名.this外部类要访问内部类必须创建内部类对象。内部类在成员位置上,可以被成员修饰符修饰。 1 public class InnerClassDemo1 { 2 public static void main(String[] args){ 3 Outer ou =new Outer(); 4 ou.method();// 4 3 5 Outer.Inner oi =new Outer().new Inner(); 6 oi.function2(... 阅读全文
posted @ 2012-06-26 23:32 Carve_Time 阅读(290) 评论(0) 推荐(1) 编辑
摘要: ★打印九九乘法表 1 public class TestDemo { 2 public static void main(String[] args){ 3 for(int b=1;b<10;b++){ 4 for(int a=1;a<=b;a++) 5 System.out.print(a+"*"+b+"="+a*b+"\t"); 6 System.out.println(); 7 } 8 } 9 10 }11 /*12 1*1=1 13 1*2=2 2... 阅读全文
posted @ 2012-06-26 23:24 Carve_Time 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 1.数组反转 1 import java.util.Arrays; 2 3 public class ArrayReverse { 4 public static void main(String[] args){ 5 int[] arr ={1,2,3,4,5,6,7,8,9}; 6 reverse(arr); 7 } 8 public static void reverse(int[] arr){ 9 for(int i=0;i<arr.length/2;i++){10 int temp = ... 阅读全文
posted @ 2012-06-26 23:23 Carve_Time 阅读(150) 评论(0) 推荐(0) 编辑
摘要: ☆ 1 public class equalsDemo { 2 public static void main(String[] args){ 3 4 /*使用==来判断两个变量是否相等时,如果两个变量时基本数据类型的 5 变量时,且都是数值类型是,则只要两个变量的值相等,使用==判断就返回true*/ 6 7 int i=65; 8 float f=65.0f; 9 System.out.println(i==f);//true10 char c='... 阅读全文
posted @ 2012-06-26 23:21 Carve_Time 阅读(148) 评论(0) 推荐(0) 编辑