Results 1 to 10 of 10
  1. #1
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default LowerBounded Wildcards

    Java Code:
    class A{}
    class B extends A{}
    class C extends B{}
    class Card<T extends B>{
    	
    	T a;
    	Card(T b){a=b;}
    	void show(Card<? super C> c){}
    	
    }
    public  class LowerBound {
    	
    
    public static void main(String[] args){
    	
    	
    	B b = new B();
    	C c = new C();
    	Card<B> cardB = new Card<B>(b);
    
    	
    	
    	cardB.show(cardC); 
    }
    }
    "show(Card<? super C> c)" this is exclusive method .. argument of type supertype of C are acceptable but here "show(Card<? super C> c)" it works fine with argment type C . whats wrong with this ? is lower bound inclusive ?
    Last edited by allaudin; 08-20-2013 at 03:41 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,782
    Rep Power
    5

    Default Re: LowerBounded Wildcards

    Does this even compile? Where is show() declared in class LowerBound? The only show I see is not even static but declared in class Card. Yet you are calling show() in a static context. Where is the closing semi-colon on show?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: LowerBounded Wildcards

    Oh sorry I copied it wrong .. I am correcting it now

  4. #4
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: LowerBounded Wildcards

    Now you can answer jim829

  5. #5
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: LowerBounded Wildcards

    Any moderator ??? why are you not answering ....

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,782
    Rep Power
    5

    Default Re: LowerBounded Wildcards

    Have patience. In any event, where is cardC instantiated (see you last statement).

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: LowerBounded Wildcards

    Oh come on ... you know what I am asking about .. leave this code ... answer my question

  8. #8
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,782
    Rep Power
    5

    Default Re: LowerBounded Wildcards

    I had every intention of helping you (or at least trying to). But if you won't at least take the time to get your code syntax free (outside of your specific problem of course) then why should I take the time. I have decided to let someone else assist you in this.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,098
    Rep Power
    6

    Default Re: LowerBounded Wildcards

    Quote Originally Posted by allaudin View Post
    Any moderator ??? why are you not answering ....
    Why do you insist on asking for moderators? You are isolating a whole group of people who are just as capable but cannot edit your posts.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  10. #10
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: LowerBounded Wildcards

    yes in my scentence, moderator means any person who knows the answer

Similar Threads

  1. Wildcards in Java
    By learn2java in forum Advanced Java
    Replies: 4
    Last Post: 05-03-2011, 12:13 AM
  2. Generics and wildcards confusion
    By castiel in forum New To Java
    Replies: 7
    Last Post: 02-23-2011, 03:37 AM
  3. Type wildcards in Generic
    By gvm in forum New To Java
    Replies: 1
    Last Post: 10-22-2010, 04:39 PM
  4. Generics and Wildcards
    By ajeeb in forum Advanced Java
    Replies: 2
    Last Post: 01-30-2009, 11:00 PM

Posting Permissions

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