Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
09-09-2009, 10:24 PM #1
How to use enums and what are "<>"?
1. I was trying to learn more about enumerations (http://java.sun.com/j2se/1.5.0/docs/...age/enums.html) and I don't exactly understand the basics of enumerations reading its first block of code (and hence I don't understand the later ones).
2. Whilst reading it, I noticed things like <Card>. What does <Card> mean?
09-09-2009, 10:40 PM #2
- Join Date
- Jun 2009
- Montreal, Canada
- Thanked 179 Times in 179 Posts
- Check this link it contains plenty of examples on how to use enums.
- The <Card> you are mentioning is called template. It defines the nature of the object that is set inside another object. For example if we declare a HashMap like this:
HashMap hm = new HashMap(); and when you put any object inside the hashmap (hm.put("id",obj) let us suppose that the obj is of type string) then when you read it you will type this:
String myObj = (String) hm.get("id"); (you are obliged to make casting other wise your data will be treated as object)
while if you define the hashmap like this:
HashMap<String> hm = new HashMap<String>(); then you are telling that all the elements inside the hashmap are of type string and when you retrieve them you do not have to cast like this:
String myObj = hm.get("id");
Software and cathedrals are much the same - first we build them, then we pray.