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

相关推荐

不愿透露姓名的神秘牛友
07-07 18:05
哈哈哈哈哈感觉朋友找工作的已经疯掉了,直接上图
码农索隆:真老板娘:“我嘞个去,这不我当年的套路吗
点赞 评论 收藏
分享
06-18 13:28
已编辑
门头沟学院 Web前端
爱睡觉的冰箱哥:《给予你300的工资》,阴的没边了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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