0

What is the syntax for List<Student>.class in Java android? This is for getting the type of list of students. Am getting a json string with List of students and that to be parsed to the concrete class.

objectMapper.readValue(response, List<Student>.class);

Sankarann
  • 2,625
  • 4
  • 22
  • 59

1 Answers1

0

From java point of view , .class file is generated when a .java file is compiled. List.java is part of core java.lang package.

The parameters we give inside the < and > like in your case Student is, dynamic.

There is no way List.class (compiled and .class generated before you created your Student class) know anything about Student.

List uses generics for this, the type is provided later, hence .class is independent of the type.

Ihor Patsian
  • 1,288
  • 2
  • 15
  • 25
nits.kk
  • 5,204
  • 4
  • 33
  • 55