บทที่ 3 พื้นฐานภาษา java
DESCRIPTION
นาย ณกาญจน์ อ่อนละออ เลขที่ 1 นาย ปัณณทัต เอกวชิราเดชากูล เลขที่ 2 นาย ชนิสร บุญแก้ว เลขที่ 4 นาย อิทธิกร ธรรมวิเศษ เลขที่ 5 นาย ณัฐวัฒน์ วรรณะ เลขที่ 6 นาย ธนานนท์ คุ้มครอง เลขที่ 8 นาย ปรินทร์ ไผทฉันท์ เลขที่ 9 นายอิทธิวัฒน์ วาสนาทิพย์ เลขที่ 12 ชั้น ม.6/1TRANSCRIPT
Public class Simple{Public static void main(String[]args){
System.out.println(“Programming is great fun!”);
}}
Simple
Simple.java System.out.println
( ; )public class
public static void main(String[]args)
main public
static
void main
print println
out System
System.out.print(data);System.out.println(data);
data print println
escape sequence
\n Newline
\t Horizontal tab
\b Backspace
\r Return
\\ Backslash \
\’ Single quote ’
\” Double quote “
print printlnescape sequence
2.3
true( ) false( )
char Unicode ‘ ‘
Unicode \u
byte, short, int long
long l L
float double float double
float f F
boolean 1 true false
char 2 Unicode
byte 1 -128 +127
short 2 -32,768 +32,767
int 4 -2,147,483,648
+2,147,483,647
long 8 -263 2
63 -
float 4 - x - - x
double 8 - x 10-308 - x
10+308
A – Z , a – z , $ _
.
final final = ;
///* */
3. /***/
total = const + tax;
- Cost = total – tax;
Tax = cost * rate;
Saleprice =
original / 2
% Ramainder = value
% 3;
–
– ,
- (unary
negation)
* / %
+ -
= X = 5; X = X + 5;
-= Y -= 2; Y = Y – 2;
*= Z *= 10; Z = Z * 10;
/= A /= b; A = A / b;
%= C %= 3; C = C % 3;
–
y = x++ y x x
-
-
Cast Operator
Cast Operator
x = (int)number;number int
x (x int )
double double
2. float
float3.
long long
String
( )Method
charAt(inde
x)
index
length()
toLowerCas
e()
toUpperCas
e()
Scanner
Scanner keyboard;keyboard
Scanner new
= new ( );keyboard
System.in keyboard = new Scanner(System.in);
Scanner
nextByte() Byte
nextDouble() Double
nextFloat() Float
nextInt() Int
nextLine()
nextLong() Long
nextShort() Short