一.变量基础题
public static void main(String[] args) {
String a = "安澈澈";
char b= 'm';
int age = 21;
int c = b;
System.out.println(a+" "+ b +" " +"人工智能");
System.out.println(age >=18?"我已经成年了":"我还未成年");
}
二.流程控制题
1.
public static void main(String[] args) {
int age = 21;
if (age>18) {
System.out.println("成年");
}else{
System.out.println("未成年");
}
}
2.
public static void main(String[] args) {
int j=1;
int total=1;
String c= "1";
while(j<=10)
{total*=j;
j++;
c = c+"*"+(j-1);
System.out.println(c+"="+total);}
}
三.数组
public static void main(String[] args) {
int[][] arr=new int[3][3];
for(int i=0;i<3;i++){
for (int j=0;j<3;j++){
Scanner sc = new Scanner(System.in);
System.out.println("输入: ");
arr[i][j]=sc.nextInt();
}}
for(int i=0;i<3;i++){
for (int j=0;j<3;j++){
System.out.print(arr[i][j]+" ");
}}
}
四.类和对象
五.面向对象2