Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: <..> when declaring a class

  1. #1
    Member
    Join Date
    Jun 2010
    Posts
    48
    Thanks
    12
    Thanked 2 Times in 2 Posts

    Default <..> when declaring a class

    Hello guys,
    I have one question. What does it mean when you put <..> in the class declaration line? Here is one example, KeyType is in there:
    when calling registerEvent method, the input to a KeyType place goes a String. How come? Can anyone explain?
    public class InternalEventManager<KeyType> {
     
        HashMap<KeyType, ArrayList<WeakReference<InternalEventListener>>> eventMap = new HashMap<KeyType, ArrayList<WeakReference<InternalEventListener>>>();
     
        public void registerEvent(KeyType type, InternalEventListener event) {
            if (!eventMap.containsKey(type)) {
                eventMap.put(type, new ArrayList<WeakReference<InternalEventListener>>());
            }
     
            ArrayList<WeakReference<InternalEventListener>> list = eventMap.get(type);
     
            WeakReference<InternalEventListener> reference = new WeakReference<InternalEventListener>(event);
     
            if (!contains(type, event)) {
                list.add(reference);
            }
        }
    Last edited by Asido; September 8th, 2010 at 06:05 AM.


  2. #2
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,235
    Thanks
    176
    Thanked 817 Times in 760 Posts
    Blog Entries
    5

    Default Re: <..> when declaring a class

    These are called generics:
    Generics

  3. The Following User Says Thank You to copeg For This Useful Post:

    Asido (September 8th, 2010)

Similar Threads

  1. declaring a "final" variable?
    By needleman in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 26th, 2010, 06:55 PM
  2. [SOLVED] Another Method,
    By Time in forum Algorithms & Recursion
    Replies: 4
    Last Post: June 28th, 2010, 09:52 PM
  3. Looking for a method,
    By Time in forum Algorithms & Recursion
    Replies: 7
    Last Post: May 15th, 2010, 12:24 PM
  4. Declaring variables in constructor and compiling
    By Newoor in forum Object Oriented Programming
    Replies: 3
    Last Post: December 5th, 2009, 12:07 PM