• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

generics java 1.5

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java 1.5 they added the ability to type Collections.

The syntax might be ArrayList<String> and now the ArrayList will only accept Strings - thus eliminating the need to cast Object back to the specific type.

It seems to me that an Object is pretty generic, so why is coding the specific type called a generic?

I suppose it doesn't matter what they call this new feature, unless there is something I don't understand about it - in which case it might be interesting to know why this feature is called generics.

Does anyone know why it's called generics?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java didn't invent the term "generics". It is a common idea that is available with many languages.

The idea is that you can declare a class myclass<E>, which E will be determined later. It is "generic" because the code is written in such a fashion using E as if it is already defined.

You are build a generic class whose definition will be defined later.

Henry
 
dave Lande
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Henry
reply
    Bookmark Topic Watch Topic
  • New Topic