经过我的尝试,发现构造函数是可以被成员函数调用的!
class Student
{
private String name;
private int age;
public Student(){}
public Student(String name,int age)
{
this.name = name;
this.age = age;
}
public static Student returnClass()
{
Student s = new Student("xiaoming",10);
return s;
}
}
class Del1
{
public static void main(String[] args)
{
Student s = Student.returnClass();
}
} |