Beruflich Dokumente
Kultur Dokumente
Programming Language
•Sun Certified Programmer for the Java 2 Platform, Standard Edition 1.2
•Sun Certified Business Component Developer for java 2 Platform,
Enterprise Edition 1.3
•IBM Test 486 Enterprise Connectivity with J2EE 1.3
•IBM Test 287 Enterprise Application Development with IBM WebSphere
Studio, V5.0
}
Demo.java
}
Demo.java
Change to E:\
utils.jar
utils.jar
package javafun.lab2;
import java.awt.*;
import java.util.Vector;
public class Demo{
}
Demo.java
package javafun.lab2;
Import java.util.Vector;
import java.awt.*;
compile
public class Demo{}
class Ok{}
class Yes{}
Demo.java
int[] a = {4,4};
a[b] = b = 0; int b = 1;
bà0
a[b] = b = 0;
a[b] = 0;
System.out.println(a[0]);
a[1] 4
a[1] = 0 System.out.println(a[1]); 0
System.out.println(b); 0
a = x ? b : c;
int j, k;
for (j = 3, k = 6; j + k < 20; j++, k +=2) {
j is 3 k is 6
System.out.println(“j is “ + j + “ k is “ + k);
j is 4 k is 8
}
j is 5 k is 10
j is 6 k is 12
BrainStream Co., Ltd.,68
For
l Can use comma to separate several
expressions.
l Con't mix expressions with variable
declarations
l Con't have multiple declarations of different
types. int i = 7;
for (i++, int j = 0; i < 10; j++) { }
for (int i = 7, long j = 0; i < 10; j++) { }
BrainStream Co., Ltd.,69
Break and continue in loops
l The break statement
– Exit from switch statements, loop statements,
and labeled block too early.
– Syntax:break <label>;
l The continue statement
– Skip over and jump to the end of the loop body
– Syntax: continue <label>;
if (<condition is true>) {
statements or blocks;
} else {
statements or blocks;
}
BrainStream Co., Ltd.,73
If
l Example
if (x > 5) {
System.out.println(“x is more than 5”);
}
if (x > 5) {
System.out.println(“x is more than 5”);
}else {
System.out.println(“x is not more than 5”);
}