创建一个Student类,要求有

.创建一个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;
}
全部评论

相关推荐

05-23 20:31
已编辑
武汉大学 Java
内向的柠檬精在研究求...:注意把武大标粗标大 本地你俩不是乱杀
实习进度记录
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务