Professional Documents
Culture Documents
Chuong Trinh Java Dau Tien Hello World
Chuong Trinh Java Dau Tien Hello World
jsp
Copyright vietjack.com
Thit lp path ca th mc jdk/bin. (Bn c th tham kho chng Cch thit lp Path
trong Java)
To v d Hello World
Bn theo di v d vit chng trnh Hello World:
class Simple{
public static void main(String args[]){
System.out.println("Hello World");
}
}
Page 1
http://vietjack.com/java/index.jsp
Copyright vietjack.com
T kha public l mt Access Modifier m biu din tnh nhn thy, ngha rng n l nhn
nht vi tt c.
String[] args c s dng cho tham s dng lnh. Bn s tm hiu v chng sau.
vit mt chng trnh n gin, bn m notepad bi Start menu -> All Programs >Accessories -> notepad v vit chng trnh n gin Hello World trn.
Vit v lu chng trnh di dng Simple.java. bin dch v chy chng trnh ny, bn cn
m dng nhc lnh command prompt bi Start menu -> All Programs -> Accessories> command prompt.
bin dch v chy chng trnh, u tin bn vo th mc hin ti, vi mnh l c:\new. Vit
y:
Page 2
http://vietjack.com/java/index.jsp
Copyright vietjack.com
Th hai, k hiu ch s di [] trong Mng Java c th c s dng sau kiu, trc bin hoc
ng sau bin. Bn theo di cc code khc nhau vit phng thc main:
public static void main(String[] args)
public static void main(String []args)
public static void main(String args[])
Th t, vic c hay khng du chm phy phn cui ca lp trong Java l ty . Bn theo di
code sau:
class A{
static public void main(String... args){
System.out.println("Hello World");
}
};
Page 3
http://vietjack.com/java/index.jsp
Copyright vietjack.com
Page 4
http://vietjack.com/java/index.jsp
Copyright vietjack.com
Page 5