-2

now I have a class looks like following:

package a.b.c;

import java.util.List;

public class FactObject {
    private double a;
    private double b;
    private List<String> c;
}

I know I could get the package name of this class by doing:

FactObject fo = new FactObject();
Class<?> c = fo.getClass();
String packageName = c.getPackage().getName();

But how can I get the imported class string, in this case, "java.util.List" ?

Thank you so much!

Cong Wang
  • 769
  • 1
  • 9
  • 30

1 Answers1

1

As you already use the class name directly in your code, the answer is given by FactObject.class.getName().

user207421
  • 305,947
  • 44
  • 307
  • 483