Generics gotchas
I found this article tonight on Generic Gotcha's, this is a good article for people who haven't yet started using Generic's and for people studying for the Java SCJP 5 exam. I also have some links from the aritcle that point to some Free PDF files on Generics in Java.
One of the best parts of any good article is the resources section and this article is no different because it has two links which are very good and they are discussed below. The article
http://www-128.ibm.com/developerworks/java/library/j-jtp01255.html
is a brief look at the more tricky parts of Generics and in particular the places where it's a bit different from the rest of Java programming. It picks up on the things that you would assume would work but don't. I liked this article because it assumes you know the basics of Generics and just focuses on the tricky parts. The reason I like this article is because its exactly the kind of article i need on Generics whislt studying for the Java Exam.
one of the biggest Generic Gotcha's is Generics are not covariant. Which means you can't put a subclass into a collection which specify's the superclass. The reason this is a gotcha because the rest of Java is covariant but I think once you understand the reasons for it, it makes sense.
I think the biggest Gotcha in Generics is the wierd placing of the unusual looking angled brackets, I have said it before but it looks a bit of a hack job. Not that I'm saying I don't think it is a good addition, I do, it just looks wierd.
Below are two really good links taken from the article
Angelika Langer has created one of the most complete (in pdf or html) files on Generics I have seen, it is over 400 pages long and probably answers any question you have about generics. It deals with Frequently asked question and any other Generic question over thought up.
http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html
Gilad Bracha also has a good tutorial which at 23 pages is much more managable. I find this tutorial pretty good and easy to follow and it's from Sun so they should know what they are talking about.
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
One of the best parts of any good article is the resources section and this article is no different because it has two links which are very good and they are discussed below. The article
http://www-128.ibm.com/developerworks/java/library/j-jtp01255.html
is a brief look at the more tricky parts of Generics and in particular the places where it's a bit different from the rest of Java programming. It picks up on the things that you would assume would work but don't. I liked this article because it assumes you know the basics of Generics and just focuses on the tricky parts. The reason I like this article is because its exactly the kind of article i need on Generics whislt studying for the Java Exam.
one of the biggest Generic Gotcha's is Generics are not covariant. Which means you can't put a subclass into a collection which specify's the superclass. The reason this is a gotcha because the rest of Java is covariant but I think once you understand the reasons for it, it makes sense.
I think the biggest Gotcha in Generics is the wierd placing of the unusual looking angled brackets, I have said it before but it looks a bit of a hack job. Not that I'm saying I don't think it is a good addition, I do, it just looks wierd.
Below are two really good links taken from the article
Angelika Langer has created one of the most complete (in pdf or html) files on Generics I have seen, it is over 400 pages long and probably answers any question you have about generics. It deals with Frequently asked question and any other Generic question over thought up.
http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html
Gilad Bracha also has a good tutorial which at 23 pages is much more managable. I find this tutorial pretty good and easy to follow and it's from Sun so they should know what they are talking about.
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
2 Comments:
Nice idea with this site its better than most of the rubbish I come across.
»
By Anonymous, at Fri May 19, 06:06:00 pm 2006
Super color scheme, I like it! Good job. Go on.
»
By Anonymous, at Fri May 19, 07:19:00 pm 2006
Post a Comment
<< Home