摘要: // Superclass (parent class)class Fruit{ public String flavor;}// Subclass (child class)class Apple extends Fruit { public String variety;}//downcastingApple a = new Apple();Fruit f = a;Apple c ... 阅读全文
posted @ 2014-08-09 02:25 星月石 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 重载 class MyRectangle{ int x, y; public MyRectangle() { x = 10; y = 20; } public MyRectangle(int a) { x = a; y = a; } public MyRectangle(int a, int b) { x = a; y = b; ... 阅读全文
posted @ 2014-08-09 02:23 星月石 阅读(272) 评论(0) 推荐(0) 编辑
摘要: While 和 Do-While //whileint i = 0;while (i < 10) { System.out.print(i++);}//do - while int i = 0;do { System.out.print(i++); } while ( i < 10 );For 和 Foreach for (int i = 0; i < 10; i+... 阅读全文
posted @ 2014-08-09 02:18 星月石 阅读(348) 评论(0) 推荐(0) 编辑
摘要: if (x 1) System.out.print(x + " > 1");else System.out.print(x + " == 1");Switchswitch (y){ case 0: System.out.print(y + " is 0"); break; case 1: System.out.print(y + " is 1"); break; default:... 阅读全文
posted @ 2014-08-09 02:15 星月石 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 数组声明,分配, 赋值 int y[] = new int[3];y[0] = 1;y[1] = 2;y[2] = 3;int[] x = new int[] {1,2,3};int[] x = {1,2,3};二维数组String[][] x = {{"00","01"},{"10","11"}};String[][] y = new String[2][2];y[0][0] = "00";y[... 阅读全文
posted @ 2014-08-09 02:12 星月石 阅读(1517) 评论(0) 推荐(0) 编辑
摘要: 组合吃烤串的各种方法 String a = "Hello";String b = new String(" World");//在循环里面的话要小心用String c = a+b; // Hello World a += b; // Hello WorldString x = "Hello " + "World";比较字符串boolean x = a.equals(b); // ... 阅读全文
posted @ 2014-08-09 02:08 星月石 阅读(749) 评论(0) 推荐(0) 编辑
摘要: 算术运算符 float x = 3+2; // 5 // addition 加x = 3-2; // 1 // subtraction 减x = 3*2; // 6 // multiplication 乘x = 3/2; // 1 // division 除x = 3%2; // 1 // modulus (division remainder) 余数Combined assignment ope... 阅读全文
posted @ 2014-08-09 02:04 星月石 阅读(465) 评论(0) 推荐(0) 编辑
摘要: // 单行注释 /* 多行 注释 */ /** java文档 */ 阅读全文
posted @ 2014-08-09 02:02 星月石 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 数据类型 类型 bits/byte 范围 默认值 byte 8/1 -128 +127 0 short 16/2 -32,768+32,767 0 int 32/4 -2,147,483,648 = -231+2,147,483,647 = 231-1 0 long 64/8 -9,223,372,036,854,775,808 = -263+9,223,372,036,8... 阅读全文
posted @ 2014-08-09 01:59 星月石 阅读(278) 评论(0) 推荐(0) 编辑
摘要: public class MyApp { public static void main(String[] args) { System.out.print("Hello World"); }} 阅读全文
posted @ 2014-08-09 01:57 星月石 阅读(199) 评论(0) 推荐(0) 编辑