2012年5月25日 星期五

Java 基礎(21)- use of super

class brother
{
brother()
{
System.out.println("Hai sister!! did you call me ?"); 
}
}
class sister extends brother
{
sister()
{
super(); //Hear super is used to call constructor of super class
}
}

class one

{
public static void main(String args[])
{
sister object = new sister();
}
}










Java 基礎(20)- INHERITANCE



Java 基礎(19)- var-arg with overloading


Java 基礎(18)-Vararg

這是錯的範例,因為VARARG只能用於同一類型




Java 基礎(17)-Simple array and list




Java 基礎(16)-Nested and Inner Classes


Java 基礎(15)-Simple array and length



Java 基礎(14)-use of Static




Java 基礎(13)-Recursion

class one
{
static void run(int num)
{
System.out.println(num);
if (num > 0)
{
run(num-1);
}

}
public static void main(String args[])
{
run(10);
}

}




Java 基礎(12)-Construtor override and return int



Java 基礎(11)-Object and parameter

import java.util.*;

class test{

int num;
int num2;

test()
{
System.out.println("Enter two number");
Scanner scan = new Scanner(System.in);
num = scan.nextInt();
num2 = scan.nextInt();
}
void compare(test obj)
{
if(obj.num==num && obj.num2==num2 && obj.num2==num && obj.num==num2)
{System.out.println("They are all same");}
else if(obj.num==num2 || obj.num2==num2 || obj.num==num || obj.num2==num)
{System.out.println("They have two number is the same");}
else
{System.out.println("They are all not same");}
}



}
public class MyEight {

public static void main(String args[])
{
test object = new test();
test object1 = new test();
object.compare(object1);
}

}






Java 基礎(10)-Construtor and override



Java 基礎(9)-Class,object and function(2)

import java.util.Scanner;

public class MySeventh
{
static void odd_or_even(int d)
{
if(d%2==0)
System.out.println("Numebr " + d + " is oven");
else
System.out.println("Numebr " + d + " is odd");
}
static void add(int a,int b)
{
int c = a+b;
System.out.println("Addition result is = " + c);
odd_or_even(c);
}
static void sub(int a,int b)
{
int c = a-b;
System.out.println("Subtraction result is = " + c);
odd_or_even(c);
}
static void mul(int a,int b)
{
int c = a*b;
System.out.println("Multipy result is = " + c);
odd_or_even(c);
}
static void div(int a,int b)
{
int c = a/b;
System.out.println("Divided result is = " + c);
odd_or_even(c);
}


public static void main(String args[])
{
System.out.println("Enter two number");
Scanner scan = new Scanner (System.in);
int k = scan.nextInt();
int l = scan.nextInt();
System.out.println("What do you want with this numbers ? 1-Add 2-Subtract 3-Multipy 4-Divide");
int fun = scan.nextInt();
switch (fun)
{
case 1:
add(k,l);
break;
case 2:
sub(k,l);
break;
case 3:
mul(k,l);
case 4:
div(k,l);

}
}
}

Java 基礎(8)-Class,object and function



Java 基礎(7)-Class and object


Java 基礎(6)-Switch & Case

import java.util.*;

public class MyFive {

public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter number 1 to 7 and i will tell you what is it");
System.out.println("Enter number : ");
int number = scan.nextInt();
switch (number)
{
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thurday");
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
default:
System.out.println("You are not enter number 1 to 7 :( Don't fool me! ");
}

}

}

Java 基礎(5)-Do & while

class dowhile
{
public static void main(String args[])
{
int i =0;
do
{
i = i+1;
System.out.println("Hai");
}
while(i<10);
}
}




2012年5月24日 星期四

Java 基礎(4)-break and continue

class break_and_continue
{
public static void main(String args[])
{
for (int i=0;i<10;i++)
{
if (i%2 == 0)
{
continue;
}
System.out.println(i);
}
}





public static void main(String args[])
{
for(int i=1; i<=100; i++)
{
if (i==5)
{
continue;
}
if(i==7)
{
continue;
}
if(i==23)
{
break;
}
System.out.println(i);
}
}

Java 基礎(3)-for loop,if & else

import java.util.*;

class MyThird{

public static void main(String args[])
{

Scanner scan = new Scanner(System.in);
System.out.println("You can enter the number 5 times ");
System.out.println("Enter the number: ");
for(int i=0; i<5; i++)
{
int number = scan.nextInt();


if (number == 0)
System.out.println("Number is Zero");
else
if (number%2 == 0)
{
System.out.println("Number: " + number);
System.out.println("Number is Even");
}
else
{
System.out.println("Number: " + number);
System.out.println("Number is Odd");
}

}
System.out.println("this is end of this program");

}
}


Java 基礎(2)-calculate

import java.util.*;
class number
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
System.out.println("Number please : ");
int number = scan.nextInt();
if (number == 0)
System.out.println("Number is Zero");
else
if (number%2 == 0)
System.out.println("Number is Even");
else
System.out.println("Number is Odd");

}
}




Java 基礎-scanner and import




mport java.util.*;

public class MySecond {

public static void main(String args[])
{
System.out.println("Hello,Please enter your name");
Scanner text = new Scanner(System.in);
int Age = text.nextInt();
System.out.println(Age);
}

}


美語單詞(21)


spermicide 殺精子劑
relic 遺物; 遺風, 遺俗 紀念物
dearth 缺乏, 不足
coarse 粗俗的, 粗魯的; 猥褻的
defamation 誹謗; 中傷
libel ...造謠中傷 【律】(利用文字、圖畫等的)誹謗()
saliva , 唾液
puritanical 道德上嚴格的; 禁慾的
garnish 裝飾; 添加配菜於
platonic 理想的; 不切實際的 柏拉圖(哲學) 兩性之間關係)純精神友誼的
tidbits 趣聞; 小欄報導, 花絮
bristle (男子下巴上的)粗硬短鬚
behoove...有此必要
hurdles 障礙, 困難
surmountable 可克服的; 可超越的
dissimilarities 不同, 相異; 相異點
latent 潛伏的, 潛在的
fragility 脆弱; 易碎性
umbrage 陰影 憤怒, 生氣
chaste 貞潔的; 純潔的; 在性關係上嚴肅的
aberrant 偏離正道的, 脫離常軌的 【生】畸變的; 異常的
snide 險惡的; 惡意的 騙子
virtue 美德, 德行
turf 【美】【俚】地盤; 勢力範圍


美語單詞(20)


desperate 極度渴望的
condolence )弔辭; 弔唁; 慰問
intrude 侵擾, 打擾
estrogen ()激素
inadvertent 不注意的; 怠慢的
consensual 【律】在雙方同意下成立的
proactive 【心】前攝的
eligible (尤指婚姻等)合適的, 合意的
reconvene 再聚會; 再集會
testosterone 【生化】【藥】睪(), 睪丸素(一種男性荷爾蒙)
absurd 不合理的, 荒謬的; 可笑的, 愚蠢的
coercion 強制; 強迫
futile 無益的, 無效的, 無用的; 無希望的 忙於小事的; 缺少目的的
condemn 責難, 責備, 譴責
orgies 狂歡; 縱慾; 縱酒 無節制行為
hunch 預感, 直覺
gross 【俚】令人噁心的; 令人討厭的 顯著的, 十足的; 嚴重的; 惡劣的[B]
errant 迷路的; 走入歧途的 周遊的; 漂泊的; 遊歷的

美語單詞(19)


Deliberate 故意的, 蓄意的 深思熟慮的, 慎重的, 謹慎的 不慌不忙的, 從容的
tenuous 貧乏的; 平淡的 脆弱的, 無力的
wedge 導致分裂的事物, 事情的起因
snippy 【口】很粗魯的; 傲慢的
dignity 尊嚴; 莊嚴
libido 性慾
deluding 欺騙; 哄騙; 迷惑[
feign 【文】裝作, 假裝
bolster 支持物; 承板; 承材
perpetuate 使永久存在; 使不朽
dull 乏味的, 單調的, 令人生厭的
antagonizing 使對抗; 使敵對
brutal 嚴酷的, 苛刻的
blunt 耿直的, 直率的; 直言不諱的 (頭腦, 感覺等)遲鈍的
volatile 易變的; 反覆無常的; 輕浮的
forgo 放棄, 拋棄 ...斷念, 棄絕

美語單詞(18)


curmudgeon 吝嗇鬼 存心不良的人 難以取悅的人; 壞脾氣的人
toad 蟾蜍, 癩蛤蟆 令人討厭的人, 卑鄙小人
acrimony (言語、態度等的)尖刻; 厲害; 辛辣; 激烈
booth 【美】公用電話亭; 崗亭 (隔開的)小房間; (餐廳等的)雅座
fundamentally 基礎地; 根本地; 重要地
hussy 輕佻的女子
badge 【美】【俚】警察 標誌, 標記; 象徵
indictment 控告, 告發; 起訴
refrain 疊句; 副歌 忍住; 抑制, 節制; 戒除