如何将 tom.name、id 年龄和年份变量从 main 方法传递到“tomdetails”方法中,以便该方法可以识别它们?
class Student {
int id;
int age;
int year;
String name;
}
class Staff {
int id;
int age;
String name;
String postcode;
String department;
}
public class Main {
public static void main(String[] args) {
//Database
//Students
Student tom = new Student();
tom.name = "Tom";
tom.id = 1;
tom.age = 15;
tom.year = 10;
}
private static void tom_details() {
System.out.println(tom.name);
System.out.println(tom.id);
System.out.println(tom.age);
System.out.println(tom.year);
}
}
喵喔喔
HUH函数
相关分类