View Full Version : How to use enums and what are "<>"?
Apothem
09-09-2009, 09:24 PM
1. I was trying to learn more about enumerations (http://java.sun.com/j2se/1.5.0/docs/guide/language/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?
ckeyrouz
09-09-2009, 09:40 PM
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");
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.