Is there a Template Class in Java as in C++, or is Object class in Java similar to Template class in C++ or at least the concepts...

Recommended Answers

All 2 Replies

Is there a Template Class in Java as in C++, or is Object class in Java similar to Template class in C++ or at least the concepts...

Study Generics/Erasure in Java. It's similar to C++ Templates, but has a major compile-time difference.

In Java instances of Erasure types, as the name implies, are erased during compile-time.

In C++ instances of Erasure types are instantiated(produced) during compile-time.

Whoops I meant in C++ instances of Templates are instantiated, not Erasure @_@

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.