顯示具有 Java 標籤的文章。 顯示所有文章
顯示具有 Java 標籤的文章。 顯示所有文章

2010年7月25日 星期日

[Spring] Eclipse 安裝Spring IDE

安裝Spring IDE前需先安裝 Graphical Editing Framework (GEF)

再安裝Spring IDE

Help > Software Updates > Find and Install.


新增一個位址:
http://springide.org/updatesite




















Introduction to Spring IDE 2.0

2010年7月13日 星期二

[Java] 相關技術名詞筆記

Java SE - Standard Edition (開發與部署你的Java應用程式到作業系統或伺服器)
Java ME - Micro Edition (開發手機, PAD...等的應用程式)
Java EE - Enterprise Edition (企業級應用平台, 軟體架構, 設計思想)

  • Struts - 採用Java Servlet/JSP技術,實現了基於Java EE Web應用的Model-View-Controller〔MVC〕設計模式的應用框架〔Web Framework〕
  • Hibernate - ORM (Object/Relational Mapping) 一種Java語言下的物件關聯對映解決方案
  • Spring Framework - is an open source application framework for the Java platform
    • IoC - Inversion of Control 控制翻轉
    • AOP (Aspect-Oriented Programming)




JavaFX - 創建Rich Internet application ( RIAs )
JSP - Java Servle Page


Apache Tomcat - Web Server

2010年7月7日 星期三

[Java] Permutation 排列組合

/**
 * 
 * Permutation 排列組合
 *
 */

public class Permutation {

 static int MAX = 10;
 static int solution[] = new int[MAX];
 static boolean used[] = new boolean[MAX];
 
 public static void main(String[] args) {
  // 列出 0~9的排列組合
  // Permutation(0, 10);
  // 列出 0~4的排列組合
   Permutation(0, 5);
 }
 
 public static void Permutation(int k, int n) {
  int i;
  if(k==n){
   for (i=0; i < n; i++)
    System.out.print(solution[i]);
   System.out.println();
  } else {
   for (i=0; i < n; i++) {
    if (!used[i]) {
     used[i] = true;
     solution[k] = i;
     Permutation(k+1, n);
     used[i] = false;
    }
   }
  }
 }
}

2010年7月5日 星期一

[Java ]Java 4-Ever Trailer

Java 4-Ever Trailer By JavaZone





(Scene: A father and his son playing “throw-and-catch”)
(場景: 一位父親和兒子玩丟接球遊戲)

Narrator: They appear to be a perfect family
旁白: 他們看起來像是一個完美的家庭…

(Scene: bedtime story)
(場景: 床邊故事)

Father: Export all OLE objects with the command line
父: 以命令行輸出所有的OLE物件

Father: So that they will be available for Internet information
父: 所以它們能為網際網路資訊所用

Son: Dad?
子: 爸爸?

Narrotor: But sometimes appearances can be deceiving.
旁白: 但是有些時候外表是假像

Son: Why do we always use .Net?
子: 為什麼我們總是使用.Net?

Father: What do you mean?
父: 你說什麼?

Son: Are there no other developing platforms?
子: 沒有其它的發展平臺嗎?

Father: I think it’s time for you to go to sleep!
父: 我想你該睡了!

Narrator: As a young boy discovers a new world unfolding
旁白: 當一個年輕小夥子發現一個新世界就此展開

(Scene: Son’s growth)
(場景: 兒子的成長)

Son & Peer: Look how beautiful, robust, secure, portable, and scalable it is!
兒子與夥伴: 看到沒! 它多漂亮、堅固、安全、可攜帶性和可擴展性!

Father: Hey, what are you guys up to?
父: 嗨, 你們這些傢伙在幹嘛?

Son: We are just enjoying some porn.
子: 我們只是在看色情影片.

Father: Hope you’re not doing Java and open source…
父: 希望你們不要弄些Java和開源的東西…

Son & peer: No!
兒子與夥伴: 沒!

Father: Good!
父: 很好!

Narrator: For being young is all about experimenting
旁白: 因為年輕就是要不斷試驗

Father: What are you doing in there?
父: 你在裡面做什麼?

Son: Nothing!
子: 啥都沒!

Father: Hello?
父: 哈囉?

Son: Yeah, I’m almost done!
子: 耶, 我快好了!

(Scene: Christmas Dinner, son’s confession, and father’s death)
(場 景: 耶誕節晚餐, 兒子的告白, 和父親的死)

Family: Merry Christmas!
(全家: 聖誕快樂!)

Narrotor: But a secret can’t stay a secret forever…
旁白: 但是秘密沒有辦法永久是秘密…

Son: Dad…
子: 爸爸…

Son: Mom..I have a confession to make.
子: 媽媽..我有事要坦白.

Son: I use Java!
子: 我用Java!

Father: What the hell are you talking about?
父: 你說什麼鬼啊?

Son: I want to use a programming language which doesn’t only run in Windows.
子: 我要使用不單單只是在Windows中跑的程式語言.

Father: That’s just wrong!
父: 那是大錯特錯!

Son: Portability has never been a priority for Microsoft, and you know it.
子: 可攜性從來不是微軟優先考慮的, 你是知道的.

Mother: My son is a monster!
母: 我兒子是怪物!

The java Post: “One of the most compelling dramas for our time…”
Java 郵報: “一個屬於我們年代最驚天動地的戲劇…”

Father: Microsoft gives us net based applications…
父: Microsoft給了我們網上應用程式…

Father: that share information with other applications via web servers.
父: 可以經由網站伺服器和其它應用程式分享資訊.

Wired: “Truly gripping…”
連線雜誌: “實在扣人心弦…”

Father: They actually enable us to send XML-messages…
父: 它們實在可以讓我們傳送XML-訊息…

Father: …through SOAP! Through SOAP!
父:…藉由SOAP! 藉由SOAP!

Son: Shouldn’t you be able to make your own choices, based on your own needs?
子: 你難道不該可以基於你自己的需求做自己的選擇嗎?

(Scene: The father ripps off his son’s shirt and sees a tattoo of an arrow heart with Java on it. The father faints away and dies)
(場景:父親扯 掉兒子的襯衫, 看到一個一箭穿心的刺青, 心上還寫個Java. 父親昏倒死掉了)

Son: Dad?
子: 爸?

James Gosling: “…a masterpiece!”
James Gosling(Java之父): “…曠世之作!”

(Scene: The graveyard, the son’s grievous confession, and the hot girl.)
(場景: 墓園、兒子的哀傷告白和辣妹.)

Narrotor: But sometimes the truth comes with the terrible price.
旁 白: 但是, 有時候真相帶來可怕的代價.

Son: Maybe you were right, dad.
子: 也許你曾是對的, 爸.

(Epitaph: John Johnsen, 1951-2011, Where do you want to go today?)
(碑 文: John Johnsen, 1951-2011, 今天你想往哪兒?)

Son: Maybe .NET is better than Java.
子: 也許.NET是比Java好.

Son: Maybe it’s easier if Microsoft sets the standard…
子: 也許那會(生命)會輕鬆些, 如果Microsof定下了標準…

Hot girl: Java is far better!
辣妹: Java是大大的好!

Hot girl: You can do fine tuning and balancing which you can’t do with Microsoft.
辣妹: 你可以做超好的優化和負載平衡, 這些是你無法以Microsoft做到的.

Hot girls: Java is the future!
辣妹: Java是未來!

Narrotor: From a clean director of JAVATAR and .NOT
旁白: 來自JAVATAR and .NOT的一個無懈可擊的導演.

Narrotor: starring Eddie Larrison, Scala Johansson, two-time-golden-doo winner William Windows
旁白: Eddie Larrison、Scalla Johansson和兩度金愚獎得主William Windows領銜主演

Father: Goddammit!
父: (粗口)

Narrotor: and a compelling performance by Mona Lisa Harddrive
旁白: 和Mona Lisa Harddrive的優異演出

Narrotor: and introduing Lenny Linux
旁白: 在此介紹Lenny Linux

Narrotor: Java 4-ever
旁白: Java永生!

[Java] 運算子優先順序Operator Precedence

Operator Precedence
OperatorsPrecedence
postfixexpr++ expr--
unary++expr --expr +expr -expr ~ !
multiplicative* / %
additive+ -
shift<< >> >>>
relational< > <= >= instanceof
equality== !=
bitwise AND&
bitwise exclusive OR^
bitwise inclusive OR|
logical AND&&
logical OR||
ternary? :
assignment= += -= *= /= %= &= ^= |= <<= >>= >>>=

Reference from : http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html

2010年7月2日 星期五

[JAVA] 龜兔賽跑-Turtle_Rabbit_Race

/************************************************
*  Comment: 龜兔賽跑   
*  1. 請輸入跑道長度(跑道長度 介於10-30):
*  2. 若跑道長度沒有介於10-30之間,請使用者重新輸入
*  3. 烏龜一次走動的長度為1-2,
*     兔子一次跳躍的長度為0-3
*  4. 每到一個定點,即於定點上填入1,其餘則為 0
*  5. 並於烏龜或兔子到達終點時,顯示出如範例所示之比賽過程,並告知烏龜或兔子贏的訊息(若平手即顯示平手訊息)

 輸出範例:
 
 ----95年龜兔賽跑----
 請輸入跑道長度(10-30):5
 請重新輸入跑道長度(10-30):35
 請重新輸入跑道長度(10-30):20

 比賽過程
 烏龜 :0 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 0 1 1 1
 兔子 :0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 1
 平手

 烏龜 :0 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 0 1 1 0
 兔子 :0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 1
 兔子獲勝
*  
*  
*  Author: Han-Hong Wang
*  Website: http://whhnote.blogspot.com
*  E-mail: phodra@hotmail.com
*  Develop Environment-Compiler: J2SE 1.6.0
*        -Editor: Eclipse 3.2.0   
*        -OS: Windows XP SP2   
*  Creation Date: 2006/12/27     
*  Last Update: 2010/07/02      
*************************************************/

import java.util.Scanner;

public class Turtle_Rabbit_Race {
 public static void main(String[] args) {
  Scanner scanner = new Scanner(System.in);
  System.out.println("----95年龜兔賽跑----");
  int RunwayRange=0;
  
  //Get Runway Range
  System.out.print("請輸入跑道長(10-30): ");
  while (RunwayRange==0) { 
   RunwayRange = scanner.nextInt();
   if ((RunwayRange<10)||(RunwayRange>30)) {
    System.out.print("請重新輸入跑道長度 (10-30): ");
    RunwayRange=0;
   }
  }
  
  //Run Start
  int rabbitStep[] = new int[RunwayRange+1]; //兔子步數記錄(0-3)
  int turtleStep[] = new int[RunwayRange+1]; //烏龜步數記錄(1-2)
  int rabStep=0; //兔子步數(0-3)
  int turStep=0; //烏龜步數(1-2)
  
  while (rabStep<RunwayRange && turStep<RunwayRange) { 
   rabStep += (int)(Math.random()*4); //兔子這次跑的步數
   if (rabStep>RunwayRange) {rabStep=RunwayRange;}
   if (rabStep!=0) {rabbitStep[rabStep-1] = 1;} //記錄兔子這次跑的位置
   
   turStep += 1+(int)(Math.random()*2); //烏龜這次跑的步數
   if (turStep>RunwayRange) {turStep=RunwayRange;}
   turtleStep[turStep-1] = 1; //記錄烏龜這次跑的位置
  }
  
  int i;
  System.out.print("兔子 : ");
  for (i=0;i<RunwayRange;i++) {
   System.out.print(rabbitStep[i]);
  }

  System.out.println();
  System.out.print("烏龜 : ");
  for (i=0;i<RunwayRange;i++) {
   System.out.print(turtleStep[i]);
  }
  
  //分出勝負
  System.out.println();
  if (rabStep > turStep) {
   System.out.println("兔子獲勝!!");
  } else {
   if (rabStep == turStep) {
    System.out.println("雙方平手!!");
   } else {
    System.out.println("烏龜獲勝!!");
   }
  }
 }
}

2009年6月9日 星期二

[Java] 計算自己已經活了幾天 calculate your age in days

由 cal.set 設置生日日期, 例如我的生日: 1985-01-30
cal.set(1985, Calendar.JANUARY, 30);

Run

$ javac LiveDay.java
$ java LiveDay

我已經活了 10339 天

[Java] Pacman 小精靈 - 簡易版

很久以前用VB寫過的,把他改寫成Java @Q@

圖片要放在./images/

C.gif
U.gif
R.gif
L.gif
D.gif


Note:

1. 可再加入判斷左右邊界功能
2. 畫出地圖
3. 增加敵人

2008年12月17日 星期三

[Java] 字串反轉


String s = new StringBuffer("abc").reverse().toString();
System.out.println(s);

結果為 cba

2008年6月5日 星期四

安裝JDK (Java Develpment Kit) on Windows

http://java.sun.com/

設定Path:

我的電腦右鍵-> 內容 -> 進階 -> 環境變數 -> Path裡加入
C:\Program Files\Java\jdk1.6.0_14\bin

Step By Step 影片
Related Posts Plugin for WordPress, Blogger...