Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Thanked 25 Times in 25 Posts

    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?

  2. #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Montreal, Canada
    Thanked 179 Times in 179 Posts
    1. Check this link it contains plenty of examples on how to use enums.
    2. 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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts