It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Does java support templates? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Does java support templates?" Watch "Does java support templates?" New topic
Author

Does java support templates?

Inuka Vincit
Ranch Hand

Joined: Aug 10, 2004
Posts: 175
For all the time I used Java I thought it didnt then I ran across this:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashSet.html

can any boy elaborate.

Thanks


MCP (C# application dev 70-316) 860<br />SCJP 1.4 100% SCJD (URLyBird) 378<br />MAD 100% nuts
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Java 1.5 - currently in beta - introduces templates ("generics") into the language. If you're familar with C++, beware: they are reminiscent of C++ templates and are superficially similar, but they work quite differently under the hood.

- Peter
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Peter den Haan:
Java 1.5 - currently in beta - introduces templates ("generics") into the language. If you're familar with C++, beware: they are reminiscent of C++ templates and are superficially similar, but they work quite differently under the hood.


In fact, Java does *not* use templates to implement generics.

C++ templates use a compile-time model. When a template is used in a C++ program, the effect is as if a sophisticated macro processor had been used.

Java generics (as well as C# generics) are not just a feature of the compiler, but also a feature of the runtime. A generic type such as List<T> maintains its generic-ness (genericity) after it has been compiled.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Ilja Preuss:
In fact, Java does *not* use templates to implement generics.
That's what I was trying to warn about. Semantics, you've gotta love 'em Thanks

- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does java support templates?
 
Similar Threads
Formatting doubt
Storing data into excisting Data
printf( ) method ...
Help - Exam Watch about Collection -K&B
HashSet Capacity