網(wǎng)易微專(zhuān)業(yè) Java開(kāi)發(fā)工程師(Web方向)
安裝Eclipse和Java SRE
Hello.java
ALT+/ 補(bǔ)全
CTRL+/ 取消注釋
package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World"); //print line 換行
Scanner in = new Scanner(System.in); //準(zhǔn)備讀取條件
int price = 0;
price = in.nextInt(); //正式讀取整數(shù)
System.out.println("100-"+price+"+"+(100-price));
}
}
final int amount = 100; //常量
inch = in.nextDouble(); //讀取浮點(diǎn)數(shù)
判斷浮點(diǎn)數(shù)是否相等 Math.abs(f1 - f2) < 0.00001;
判斷
Scanner in = new Scanner(System.in);
int type = in.nextInt();
switch(type)
{
case 1:
case 2:
System.out.println("你好");
break;
case 3:
System.out.println("晚上好");
break;
case 4:
default:
}
判斷
while 當(dāng)
int 4byte
[-231 ~231 -1]
for == while
for (int i = 1; i <= n; i = i+1)
{
factor = factor * i;
}
||
||
int i = 1;
while (i <= n)
{
factor = factor * i;
i = i + 1;
}