.创建一个Student类,要求有姓名,年纪,性别,是否单身属性,再创建一个静态方法,在静态方法中创建对象,给对象属性赋值,然后将对象返回给main方法
package work001;
public class Student001 {
public static void main(String[] args) {
student a = new student();
System.out.println(a.name+a.age+a.sex+a.danshen);
}
}
class student{
String name;
int age;
String sex;
boolean danshen;
public static String a(){
Student s =new Student();
a.name="tom";
a.age=18;
a.sex="man";
a.danshen=false;
return a;
}
京公网安备 11010502036488号