面向对象//if else while,for循环语句等语法和C是一样的
基础
import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
//System.out.println("你好");
Scanner in = new Scanner(System.in);
// System.out.println("echo:"+in.nextLine());//加号连接字符串
System.out.println("输入身高");
double itch = 0;
int foot = 0;
foot = in.nextInt();
itch = in.nextDouble();
//类型转换(Element)(运算)
System.out.println((int) ((foot + itch / 12) * (0.3048) * 100) + "cm");
// System.out.println((10/3*3));//输出9
// System.out.println((10/3.0*3));//输出10.0
// System.out.println((10.0/3.0*3));//输出10.0
// shift+方向键+ctrl+/
//多路分支
int type = 0;
type = in.nextInt();
switch (type) {
case 1:
case 2:
System.out.println("hello");
break;
case 3:
System.out.println("bye");
break;
default:
System.out.println("what");
break;
}
//随机数 Math.random();
// /数组
int[] a=new int[100];
int[] b=new int [a.length];
int[] data=new int[100];
int x;
boolean found=false;
for(int k:a)//每次循环将数组a里面的值赋值给k,只是值的对应关系,与位置无关
{
if(k==x){found=true;}
}
}
}