网易微专业 Java开发工程师(Web方向)
安装Eclipse和Java SRE
Hello.java
ALT+/ 补全
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); //准备读取条件
int price = 0;
price = in.nextInt(); //正式读取整数
System.out.println("100-"+price+"+"+(100-price));
}
}
final int amount = 100; //常量
inch = in.nextDouble(); //读取浮点数
判断浮点数是否相等 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 当
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;
}