2014年4月17日 星期四

Oracle Database

-- 建立新的TABLE
CREATE TABLE
    NEW1TABLE
    (
        AA NUMBER ,
        BB CHAR(1) ,
        CC VARCHAR2(10),
        DD CHAR(10)
    );

--變更TABLE名稱
ALTER TABLE NEW1TABLE RENAME TO FIRSTTABLE;

2011年8月27日 星期六

身分證字號驗證

public class idTest {
    private static int x=0, y=0;//轉換英文代表的數字

    public idTest(){
    }
    public static void main(String[] args) throws IOException {
        String id;
        char[] idChar;

        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("請輸入身分證字號:");

        id = buf.readLine();
        if(id.length() != 10){
            System.out.println("id長度錯誤。");
            System.exit(0);
        }

2011年8月21日 星期日

sort排序 練習

//sort排序
        int ary[] = {120,-10,-30,3,20,150,30,150};
        String temp = "";
        for(int i = 0;i <ary.length; i++){
            temp += ary[i]+"\t";
        }
        System.out.println("排序前的ary : "+temp);

氣泡排序 練習

//氣泡排序
        int ary[] = {120,-10,-30,3,20,150,30,150};
        int swap;
        String temp = "";
        for(int i = 0;i < ary.length;i++){
            temp += ary[i]+"\t";
        }
        System.out.println("排序前的ary: "+temp);
        temp="";
        for(int i = 0;i < ary.length-1;i++){
            if(ary[i] > ary[i+1]){
                swap = ary [i];

陣列的複製 練習


//陣列的複製
        char ary1[] = {'A','A','A','A'};
        char ary2[] = {'B','C','D','E'};
        String temp1 = "",temp2 = "";
        for(int i = 0;i &lt; 4;i++){
            temp1 += ary1[i] + "\t";
            temp2 += ary2[i] + "\t";
        }
        System.out.println("複製前的ary1 :"+temp1);
        System.out.println("複製前的ary2 :"+temp2);

非對稱二維陣列 練習

public static void main(String[] args) {
        //非對稱二維陣列
        int[][] array = new int[4][];
        array[0] = new int[]{1};
        array[1] = new int[]{2,3};
        array[2] = new int[]{4,5,6};
        array[3] = new int[]{7,8,9,10};
        System.out.println("非對稱二維陣列 : ");
//        System.out.println(array[0][0]);
//        System.out.println(array[1][0]+ " " +array[1][1]);
//        System.out.println(array[2][0]+ " " +array[2][1]+ " " +array[2][2]);
//        System.out.println(array[3][0]+ " " +array[3][1]+ " " +array[3][2]+ " " +array[3][3]);