— Scott McNealy, Sun Microsystems Chairman, President and ceo


public class MyFirstApp {



Download 40,57 Mb.
Pdf ko'rish
bet34/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   30   31   32   33   34   35   36   37   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

public class MyFirstApp {
public static void main (String[] args) {
System.out.println(“I Rule!”);
System.out.println(“The World”);
}
}

Save

MyFirstApp.java

Compile
 
javac MyFirstApp.java

Run
public class MyFirstApp {
public static void main 
(String[] args) {
System.out.print(“I Rule!”); 
}
}
MyFirstApp.java
Method Party() 0 aload_0 1 
invokespecial #1 java.lang.Object()>
4 return
Method void 
main(java.lang.String[])
0 getstatic #2 File Edit Window Help Scream
%java MyFirstApp
I Rule!
The World
2
3
1
compiler


10
 
chapter 1
Once you’re inside main (or any method), the fun 
begins. You can say all the normal things that you say 
in most programming languages to make the computer 
do something. 
Your code can tell the JVM to:
1
do something
Statements: declarations, assignments, 
method calls, etc.
int x = 3;
String name = “Dirk”;
x = x * 17;
System.out.print(“x
is ” + x);
double d = Math.random();
// this is a comment
2
do something again and again
Loopsfor and while
while (x 
> 12) { 
x = x -1;
}
for (int x = 0; x < 10; x = x + 1) {
System.out.print(“x is now ” + x);
}
3
do something under this condition
Branchingif/else tests
if (x == 10) {
System.out.print(“x must be 10”);
} else {
System.out.print(“x isn’t 10”);
}
if ((x < 3) & (name.equals(“Dirk”))) {
System.out.println(“Gently”);
}
System.out.print(“this line runs no matter what”);
±
Each statement must end in a 
semicolon.
x = x + 1

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   30   31   32   33   34   35   36   37   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish