System.out.println(name="+name",age="+age",score="+score");里面能这么写吗??
类也定义的多余,没必要有student2这个类,test这个类做什么的?
给你改下,你对比下- public class Test {
- public static void main(String[] args)
- {
- Student p =new Student("zhangsan",22,25);
- }
- }
- class Student{
- private String name;
- private int age;
- private int score;
- Student(String name,int age,int score)
- {
- this.name = name;
- this.age = age;
- this.score = score;
- System.out.println("name="+name+",age="+age+",score="+score);
- }
- }
复制代码 |