1.
public class sum{
public static void main(String[] args) {
int result = 1; for(int i = 2;i <= 10;i++){
result += i;
}
System.out.println(result);
}
}
2.
public class person{
public String name;
public int age;
}
public person(String name,int age){
this.name = name;
this.age = age;
}
public String getName() { return name; }
public int getAge() { return age; }
public void setName(String name) { this.name = name; }
public void setAge(int age) { this.age = age; }
public void abc(int age,String name){
System.out.println("姓名: " + name + ", 年龄: " + age);
}
3.
public static void main(String[] args){
int max;
int a =12, b =34, c =20;
if(a > b && a > c){
max = a;
}else if(b > a && b > c){
max = b;
}else{
max = c;
}
System.out.printf("最⼤值:%d\n",max);
int min;
if(a < b && a < c){
min = a;
}else if(b > a && b > c){
min = b;
}else{
min = c;
}
System.out.printf("最⼩值:%d",min);
}