rubixibuc
rubixibuc

Reputation: 7417

Default list model and generics JAVA

When I looked at the API specification default list model it stated the class uses generic. When I went to create an instance of the class, it didn't need it or permit it. How are generics integrated with DefaultListModel, and how can it be used?

Thanks :-)

Upvotes: 2

Views: 1055

Answers (1)

ulmangt
ulmangt

Reputation: 5423

You never need to use generics because it's simply a compile time check (see Type Erasure for more details).

Essentially, once your code is compiled, generic type information is stripped away, so it's never necessary for your code to run correctly. Generics simply provide a way for the compiler to perform static checks to make sure that you are using types in a consistent/safe manner.

Upvotes: 2

Related Questions