main方法中实例化内部类报错:

public class TestGson {
public static void main(String[] args) {
Gson gson=new Gson();
TestGson testgson=new TestGson();
Student student = testgson.new Student();
student.setId(2);
student.setName("金旭东");
String strstudent = gson.toJson(student);
Object students = JSONObject.toJSON(student);
System.out.println("gosn="+strstudent+"fastjson="+students.toString());

}
class Student{
private int id;
private String name;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}
}

相关文章:

  • 2021-08-16
  • 2022-12-23
  • 2021-11-17
  • 2021-08-15
  • 2022-12-23
  • 2021-09-08
  • 2021-06-30
猜你喜欢
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2021-07-24
  • 2021-05-24
  • 2022-01-23
相关资源
相似解决方案