Thursday, December 27, 2012

JAVA基本語法

常用的基本資料型態:
int  long  double  char  boolean

宣告變數:
EX: int a,b,c;

EX: int a = 20;

變數大小寫為不同變數
apple 不等於 APPLE

宣告字元:
char A = '我'
char A = '\u6783'(Unicode字元)

Math.random() 亂數
EX: Math.random()*10   1~10之間的亂數

Math.round 四捨五入到小數第一位

對話框
JOptionPane.showInputDaiglog("")
(必須先匯入inport javax.swing.JOptionPane;)

對話框要宣告為String
String s;
S = JOptionPane.showInputDailog("");

Double.valueOf()  轉型為某種變數






No comments:

Post a Comment