public class student
{
private String name,int age;
public student ()
{
String name = "Dominic";
int age = 10;
}
public String getName()
{
return name;
}
public int getAge()
{
return age;
}
public static void main(String[] args)
{
student s= new student();
System.out.println("The name and age of employer is:");
System.out.print(s.getName()+"\tand\t"+s.getAge());
}
}
答案 0 :(得分:0)
删除构造函数中变量的类型声明。您通过添加String和int
在构造函数中声明新的变量名称和年龄更改为
(get_part(TABLE[left as usize], left) << 4) + get_part(TABLE[right as usize], right)
这样,您可以将值分配给类字段而不是本地构造函数变量。还要考虑使用它来指定字段。
age = 10;
name = "Dominick";