Java 程式設計 -- 運算式
Java 程式簡介運算式分枝迴圈陣列函數遞迴錯誤處理物件導向封裝繼承多型技巧函式庫字串數學正規表達式容器檔案網路資料庫視窗ThreadListener錯誤陷阱相關檔案相關資源教學錄影Eclipse考題解答訊息相關網站參考文獻最新修改簡體版English |
範例:基本型態class Var1 { public static void main(String args[]) { int x = 3; double y = 5.9; char c = 'a'; String s = "def"; System.out.println("x="+x); System.out.println("y="+y); System.out.println("c="+c); System.out.println("s="+s); } } 範例:加減乘除public class Hello { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Hello World!"); int x=3, y=5; int z = x+y, w=x*y; System.out.println("x="+x+" y="+y+" "+" z="+z+" w="+w); float pi = 3.14f; double e = 2.71828; System.out.println("pi="+pi+" e="+e+" pi/e="+(pi/e)); // char *s = "Hello!"; String s = "Hello!"; char a='a'; System.out.println(s+a+pi); } } |
page revision: 1, last edited: 22 Sep 2011 02:44
Post preview:
Close preview