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: Using Restricted Generics

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Using Restricted Generics - SOLVED

    Hi,

    I am using generics in a class that I am creating and want to ensure that the only type of object which is passed in is one that implements comparable. Up until this point I was under the impression that

    public Class MyClass <T Comparable>{
    ...
    }

    is the correct syntax to do so, but it seems I was mistaken. Would someone be so kind as to correct me?

    Thank you!
    Last edited by vanillalife; July 7th, 2012 at 12:41 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Using Restricted Generics

    See Bounded Type Parameters (The Java™ Tutorials > Learning the Java Language > Generics (Updated))

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

    vanillalife (July 7th, 2012)

Similar Threads

  1. Restricted user problem with Java RE 7 Update 4
    By thetechguy in forum Java Theory & Questions
    Replies: 1
    Last Post: May 23rd, 2012, 02:33 PM
  2. Generics.
    By Kumarrrr in forum Java Theory & Questions
    Replies: 1
    Last Post: December 6th, 2011, 06:53 PM
  3. Generics
    By Kerr in forum Collections and Generics
    Replies: 2
    Last Post: May 19th, 2011, 06:44 PM
  4. Generics
    By _lithium_ in forum What's Wrong With My Code?
    Replies: 21
    Last Post: December 6th, 2010, 07:08 PM
  5. Trying to somehow Compare Generics
    By Omega_ryan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 14th, 2010, 12:58 PM