摘要:        
class B {}class A {}--------------------------class C {}interface I {}-----------------------class D {}class E {}参考文献: Java Quick Syntax Reference by Mikael Olsson    阅读全文
posted @ 2014-08-09 02:47
星月石
阅读(176)
评论(0)
推荐(0)
        
            
        
        
摘要:        
enum Speed{ STOP, SLOW, NORMAL, FAST}Speed s = Speed.SLOW;switch(s) { case SLOW: break; }参考文献: Java Quick Syntax Reference by Mikael Olsson    阅读全文
posted @ 2014-08-09 02:45
星月石
阅读(539)
评论(0)
推荐(0)
        
            
        
        
摘要:        
abstract class Shape{ public int x = 100, y = 100; public abstract int getArea();}class Rectangle extends Shape{ @Override public int getArea() { return x * y; }}参考文献: Java Q...    阅读全文
posted @ 2014-08-09 02:43
星月石
阅读(162)
评论(0)
推荐(0)
        
            
        
        
摘要:        
interface MyInterface{ void exposed();}class MyClass implements MyInterface{ public void exposed() {} public void hidden() {}}public static void main(String[] args){ MyInterface i = new My...    阅读全文
posted @ 2014-08-09 02:42
星月石
阅读(135)
评论(0)
推荐(0)
        
            
        
        
摘要:        
import java.io.*;// ...FileReader in = null;try { in = new FileReader("Missing.file");}catch(FileNotFoundException e) { System.out.print(e.getMessage());}finally { if (in != null) { ...    阅读全文
posted @ 2014-08-09 02:39
星月石
阅读(187)
评论(0)
推荐(0)
        
            
        
        
摘要:        
通过关键字Final我们可以使变量成为常量。这意味着无法再给这个变量赋值,不然编译器就会报错。 class MyClass{ final double E = 2.72; // run-time constant 运行常量 final static double C = 3e8; // compile-time constant 编译常量}参考文献: Java Quick Syntax R...    阅读全文
posted @ 2014-08-09 02:31
星月石
阅读(628)
评论(0)
推荐(0)
        
            
        
        
摘要:        
引用包 import mypackage.sub.MyClass; import java.util.*; 参考文献: Java Quick Syntax Reference by Mikael Olsson    阅读全文
posted @ 2014-08-09 02:29
星月石
阅读(164)
评论(0)
推荐(0)
        
            
        
        
摘要:        
// 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
星月石
阅读(250)
评论(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
星月石
阅读(279)
评论(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
星月石
阅读(361)
评论(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
星月石
阅读(190)
评论(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
星月石
阅读(1529)
评论(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
星月石
阅读(756)
评论(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
星月石
阅读(469)
评论(0)
推荐(0)
        
            
        
        
摘要:        
// 单行注释 /* 多行 注释 */ /** java文档 */    阅读全文
posted @ 2014-08-09 02:02
星月石
阅读(246)
评论(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
星月石
阅读(284)
评论(0)
推荐(0)
        
            
        
        
摘要:        
public class MyApp { public static void main(String[] args) { System.out.print("Hello World"); }}    阅读全文
posted @ 2014-08-09 01:57
星月石
阅读(206)
评论(0)
推荐(0)
        
 
                    
                
 
 浙公网安备 33010602011771号
浙公网安备 33010602011771号