weixin_48384182
爱上纯净的蓝天
2020-08-14 11:55
采纳率: 91.7%
浏览 100

小白求助,如何解决要求??????

图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • lucklv5201
    谁家绿鲤鱼 2020-08-14 14:28
    已采纳

    public class JsonText {
    public static void main(String[] args) {
    Student student = new Student();
    System.out.println(student);
    }
    }
    class Student{
    private String name;
    private Integer age;
    private char sex;
    private float score;
    /**
    * 不建议用isPass,容易发生错误
    */
    private Boolean isPass;

    public Student() {
        this.name = "张三";
        this.age = 18;
        this.sex = '男';
        this.score = 66.6f;
        this.isPass = Boolean.TRUE;
    }
    
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex=" + sex +
                ", score=" + score +
                ", isPass=" + isPass +
                '}';
    }
    

    }

    点赞 评论
  • DoChengAoHan
    稻城傲寒 2020-08-14 12:46

    public class Test1 {
    private String name = "张三";
    private int age = 18;
    private String sex = "男";
    private double score =66.6f;
    private boolean isPass =true;

    public static void main(String[] args) {
        Test1 test1 = new Test1();
        System.out.println(test1.toString());
    }
    
    @Override
    public  String toString() {
        return "Test1{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", score=" + score +
                ", isPass=" + isPass +
                '}';
    }
    

    }

    
    
    点赞 评论
  • qq_42024009
    风丶飞 2020-08-14 13:39
    public class JsonText {
        public static void main(String[] args) {
            Student student = new Student();
            System.out.println(student);
        }
    }
    class Student{
        private String name;
        private Integer age;
        private char sex;
        private float score;
        /**
         * 不建议用isPass,容易发生错误
         */
        private Boolean isPass;
    
        public Student() {
            this.name = "张三";
            this.age = 18;
            this.sex = '男';
            this.score = 66.6f;
            this.isPass = Boolean.TRUE;
        }
    
        @Override
        public String toString() {
            return "Student{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    ", sex=" + sex +
                    ", score=" + score +
                    ", isPass=" + isPass +
                    '}';
        }
    }
    
    点赞 评论

相关推荐