Srujan Kumar Gulla
Srujan Kumar Gulla

Reputation: 5851

Generic programming in Java source code

Arrays and Collections are two basic api classes used by all java programmers. Both the classes were added in Java 1.2

Looking at Arrays class, there are 27 overloaded binarysearch methods and it has no usage of Generics where as collections is updated to use generics. Where as Collections class has 2 overloaded binary search methods.

Any reason why it is done this way or am i missing any thing?

Upvotes: 2

Views: 185

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272657

Because Java generics can only be parameterised on reference types. int, long, etc. are primitive types.

Upvotes: 6

Related Questions