1

I have some lists with different type of content (for example , ,...). How can I find out which type of content a list can save. So that i can do Stuff like:

public Listable appendElement(Listable list){
    list.add(new "content-type");
    return list;
}

My list is a self written list from a created Interface "Listable"

public interface Listable<T> 

so I need to find out what kind of T is saveable.

I create new listobjects with:

Listable studentlist<Student> = new SinglyLinkedList<>
Listable teacherlist<Teacher> = new SinglyLinkedList<>

I allready tried some stuff like (in the class SinglyLinkedList):

public T getContentType(){
    return this.T;

But of course this didnt work, cause it is no object...

I hope someones understand what I mean and can help me :)

Abgehter
  • 151
  • 1
  • 9

0 Answers0