Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 02-03-2010
Member
 
Join Date: Dec 2009
Posts: 202
Java - question on enum

Hello,
I am new to java and I have just started to coding in java. What this means:
My first question is
Code:
enum Horse
What does the word reserved enum?

Second question
What this means:
Code:
Map mp = <string,string> new TreeMap <string,string>();
That means <string,string> ? In fact, it means <> ?
Any help on these topics will be appreciated. Thanks in advance.
Reply With Quote
  #2  
Old 02-03-2010
Member
 
Join Date: Nov 2009
Posts: 335
Re: Java - question on enum

Hello,
Generics is simple, it's just that instead of defining a TreeMap which contains Objects, you specify the type of attributes TreeMap (String here). Instead of declaring new TreeMap (), you declare new TreeMap <string,string> to say that you'll use in your String TreeMap, that's all. If you need more informational on this then you can visit the sun's official site and there you can find more detailed information on this.
Reply With Quote
  #3  
Old 02-03-2010
Member
 
Join Date: Nov 2009
Posts: 583
Re: Java - question on enum

Hello,
The letters E and T or represent other classes that you defined it? is an unknown class.
For example the ArrayList class:
Code:
ArrayList <E>
When you created an ArrayList like:
Code:
List mlst = new ArrayList <String> ();
E is used becomes the object in the String class.
I hope you are understanding what I am trying to explain to you. I recommend you to read some basics of java that it the Java core syllabus, so that you can understand what is being explained.
Reply With Quote
  #4  
Old 02-03-2010
Member
 
Join Date: Nov 2009
Posts: 356
Re: Java - question on enum

Hello,
Just have a look at the following
Code:
addAll(Collection <? Extends E> c)
As E is a String, it means that the method accepts any type of collection that contains objects that inherit from String. The String is a bad example since you can not extend. In a Map you not only the class of objects but also the keys, have you:
Code:
Map <K,V>
And then the letters K and V are used as the E of the List.
Reply With Quote
  #5  
Old 02-03-2010
Member
 
Join Date: Nov 2009
Posts: 446
Re: Java - question on enum

Hello,
Have a look at the following syntax
Code:
<?>
is primarily used as part of an interface. You can also define an interface taking or returning a collection whose type is defined by the class implements. This is very useful
Code:
<E>
is often used to refer to the word Element, i.e one can do everything and anything to its code by using this.
Reply With Quote
  #6  
Old 02-03-2010
Member
 
Join Date: Nov 2009
Posts: 359
Re: Java - question on enum

Hello,
I will try to explain you the following
Code:
<E>
is often used to refer to the word Element, i.e a it can do everything and anything.
For Map is similar:
Code:
K -> Key
V -> Value
If you need any more information regarding this topic then feel free to post and we will try to help you from this.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Java - question on enum"
Thread Thread Starter Forum Replies Last Post
Basic Java question colby02184 Software Development 2 11-11-2011 05:08 PM
UML to Java question imgr8 Software Development 1 20-04-2010 01:05 PM
Which java enum should I give to the variable "followers"? KADRI Software Development 4 20-02-2010 06:24 PM
Java program to use enum in switch statement. MADGE25 Software Development 5 01-02-2010 06:12 PM
Java math question Daren Software Development 2 02-09-2009 06:33 PM


All times are GMT +5.5. The time now is 03:33 AM.