Why does java have Type when it already has Object?

I was hoping that someone could tell me why java has java.lang.reflect.Type, when everything already inherits from Object?

Could someone please give an example of a case where I would need to use a Type and not an Object?

Answers


Object is a base class for all java classes. Type is just an tag interface for all classes that represent types. It was introduced in java 1.5 because prior to java 1.5 there was no classes that represent java type except java.lang.Class. Then when generics were introduced there was a need to create some general abstraction common for Class, generic array etc. So they defined interface Type.


'Object' is the supertype for all classes, 'Class' is a class defining a class and 'Type' is a supertype that also covers primitive types (int, boolean, etc).


Need Your Help

Apache redirect after a rewrite

apache http mod-rewrite

I'm trying to figure out how to properly do this. I'm hosting a domain that used to have a website also on the same server, however the website has now been moved to a different machine, but they ...

JTable sorting int in undesired order

java swing jtable

I'm trying to create a JTable combined with DefaultTableModel. My problem is that, when I'm clicking to sort it (row with prices) it sorts incorrectly.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.