java学习48天2020/8/22
import java.util.Scanner; public class dog { private int weight; private int age; public dog(int a,int b) { weight=a;age=b; } public void set_weight(int m) {weight=m; } public void set_age(int n) { age=n; } public int get_weight() { return weight; } public int get_age() { return age; } public static void main(String []args) { dog a=new dog(10,3); System.out.println("体重:"+a.get_weight()+"年龄:"+a.get_age()); int m,n; System.out.println("重新输入体重和年龄:"); Scanner input=new Scanner(System.in); m=input.nextInt();n=input.nextInt(); a.set_weight(m);a.set_age(n); System.out.println("体重:"+a.get_weight()+"年龄:"+a.get_age()); } }
二
三例题