Difference between List and List<ClassWhat is a difference between <? super E> and <? extends E>?The difference between Classes, Objects, and InstancesDifferences between HashMap and Hashtable?Java inner class and static nested classWhat is the difference between public, protected, package-private and private in Java?Difference between StringBuilder and StringBufferDifference between wait() and sleep()Difference between HashMap, LinkedHashMap and TreeMapDifference between <? super T> and <? extends T> in JavaWhat's the difference between @Component, @Repository & @Service annotations in Spring?What is the difference between canonical name, simple name and class name in Java Class?Ways to iterate over a list in Java

What factors could lead to bishops establishing monastic armies?

Can we share mixing jug/beaker for developer, fixer and stop bath?

What purpose does mercury dichloride have in fireworks?

Those who speak do not know, those who know do not speak

Will Jimmy fall off his platform?

When do flights get cancelled due to fog?

How to reclaim personal item I've lent to the office without burning bridges?

What's the difference between a type and a kind?

Quotients of a ring of integers

How did the Time Lords put a whole "Star" in a Tardis?

Examples of fluid (including air) being used to transmit digital data?

How do I talk to my wife about unrealistic expectations?

What are the consequences for a developed nation to not accept any refugee?

Why is whale hunting treated differently from hunting other animals?

How beneficial are flaps when landing with a tailwind?

Why did Robert F. Kennedy loathe Lyndon B. Johnson?

As a supervisor, what feedback would you expect from a PhD who quits?

Why do airports remove/realign runways?

Interpretation of non-significant results as "trends"

What does the multimeter dial do internally?

What was the nature of the known bugs in the Space Shuttle software?

What does "frozen" mean (e.g. for catcodes)?

Why do Martians have to wear space helmets?

What are the effects of abstaining from eating a certain flavor?



Difference between List super T> and List


What is a difference between <? super E> and <? extends E>?The difference between Classes, Objects, and InstancesDifferences between HashMap and Hashtable?Java inner class and static nested classWhat is the difference between public, protected, package-private and private in Java?Difference between StringBuilder and StringBufferDifference between wait() and sleep()Difference between HashMap, LinkedHashMap and TreeMapDifference between <? super T> and <? extends T> in JavaWhat's the difference between @Component, @Repository & @Service annotations in Spring?What is the difference between canonical name, simple name and class name in Java Class?Ways to iterate over a list in Java






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I was going through generics in Java and I'm having trouble trying to understand where I would use the following two.



I understand that the first myList would ensure that the list only contains elements of type Integer and all it's superclasses. Now I'm trying to figure out where myList2 would fit in here.



List<? super Integer> myList;
List<Class<? super Integer>> myList2;


Edit: It's not a duplicate of the question being linked...since this is clearly regarding the use of ? vs Class<? whereas the other question is about super vs extend










share|improve this question
























  • myList2.add(Integer.class);

    – Ruslan
    Mar 25 at 21:32











  • Possible duplicate of What is a difference between <? super E> and <? extends E>?

    – LppEdd
    Mar 25 at 21:32






  • 2





    myList is a list of object instances, e.g. a List<Number> storing Integer, Double, BigDecimal, ... objects, such as 42, 3.14159, 3e9876, ... --- myList2 is a list of Class objects, i.e. a list of Integer.class, Number.class, Object.class, Serializable.class, or Comparable.class values.

    – Andreas
    Mar 25 at 21:33












  • I understand the difference between super and extends. I was just wondering where myList2 would be used.

    – AsadSMalik
    Mar 25 at 21:33






  • 1





    I can't offhand think of a use for a list of class objects, but in general you use a Class object as a way to indicate type, or as a way to determine the properties of that type.

    – another-dave
    Mar 25 at 21:53

















-1















I was going through generics in Java and I'm having trouble trying to understand where I would use the following two.



I understand that the first myList would ensure that the list only contains elements of type Integer and all it's superclasses. Now I'm trying to figure out where myList2 would fit in here.



List<? super Integer> myList;
List<Class<? super Integer>> myList2;


Edit: It's not a duplicate of the question being linked...since this is clearly regarding the use of ? vs Class<? whereas the other question is about super vs extend










share|improve this question
























  • myList2.add(Integer.class);

    – Ruslan
    Mar 25 at 21:32











  • Possible duplicate of What is a difference between <? super E> and <? extends E>?

    – LppEdd
    Mar 25 at 21:32






  • 2





    myList is a list of object instances, e.g. a List<Number> storing Integer, Double, BigDecimal, ... objects, such as 42, 3.14159, 3e9876, ... --- myList2 is a list of Class objects, i.e. a list of Integer.class, Number.class, Object.class, Serializable.class, or Comparable.class values.

    – Andreas
    Mar 25 at 21:33












  • I understand the difference between super and extends. I was just wondering where myList2 would be used.

    – AsadSMalik
    Mar 25 at 21:33






  • 1





    I can't offhand think of a use for a list of class objects, but in general you use a Class object as a way to indicate type, or as a way to determine the properties of that type.

    – another-dave
    Mar 25 at 21:53













-1












-1








-1








I was going through generics in Java and I'm having trouble trying to understand where I would use the following two.



I understand that the first myList would ensure that the list only contains elements of type Integer and all it's superclasses. Now I'm trying to figure out where myList2 would fit in here.



List<? super Integer> myList;
List<Class<? super Integer>> myList2;


Edit: It's not a duplicate of the question being linked...since this is clearly regarding the use of ? vs Class<? whereas the other question is about super vs extend










share|improve this question
















I was going through generics in Java and I'm having trouble trying to understand where I would use the following two.



I understand that the first myList would ensure that the list only contains elements of type Integer and all it's superclasses. Now I'm trying to figure out where myList2 would fit in here.



List<? super Integer> myList;
List<Class<? super Integer>> myList2;


Edit: It's not a duplicate of the question being linked...since this is clearly regarding the use of ? vs Class<? whereas the other question is about super vs extend







java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 21:37







AsadSMalik

















asked Mar 25 at 21:26









AsadSMalikAsadSMalik

3479 silver badges27 bronze badges




3479 silver badges27 bronze badges












  • myList2.add(Integer.class);

    – Ruslan
    Mar 25 at 21:32











  • Possible duplicate of What is a difference between <? super E> and <? extends E>?

    – LppEdd
    Mar 25 at 21:32






  • 2





    myList is a list of object instances, e.g. a List<Number> storing Integer, Double, BigDecimal, ... objects, such as 42, 3.14159, 3e9876, ... --- myList2 is a list of Class objects, i.e. a list of Integer.class, Number.class, Object.class, Serializable.class, or Comparable.class values.

    – Andreas
    Mar 25 at 21:33












  • I understand the difference between super and extends. I was just wondering where myList2 would be used.

    – AsadSMalik
    Mar 25 at 21:33






  • 1





    I can't offhand think of a use for a list of class objects, but in general you use a Class object as a way to indicate type, or as a way to determine the properties of that type.

    – another-dave
    Mar 25 at 21:53

















  • myList2.add(Integer.class);

    – Ruslan
    Mar 25 at 21:32











  • Possible duplicate of What is a difference between <? super E> and <? extends E>?

    – LppEdd
    Mar 25 at 21:32






  • 2





    myList is a list of object instances, e.g. a List<Number> storing Integer, Double, BigDecimal, ... objects, such as 42, 3.14159, 3e9876, ... --- myList2 is a list of Class objects, i.e. a list of Integer.class, Number.class, Object.class, Serializable.class, or Comparable.class values.

    – Andreas
    Mar 25 at 21:33












  • I understand the difference between super and extends. I was just wondering where myList2 would be used.

    – AsadSMalik
    Mar 25 at 21:33






  • 1





    I can't offhand think of a use for a list of class objects, but in general you use a Class object as a way to indicate type, or as a way to determine the properties of that type.

    – another-dave
    Mar 25 at 21:53
















myList2.add(Integer.class);

– Ruslan
Mar 25 at 21:32





myList2.add(Integer.class);

– Ruslan
Mar 25 at 21:32













Possible duplicate of What is a difference between <? super E> and <? extends E>?

– LppEdd
Mar 25 at 21:32





Possible duplicate of What is a difference between <? super E> and <? extends E>?

– LppEdd
Mar 25 at 21:32




2




2





myList is a list of object instances, e.g. a List<Number> storing Integer, Double, BigDecimal, ... objects, such as 42, 3.14159, 3e9876, ... --- myList2 is a list of Class objects, i.e. a list of Integer.class, Number.class, Object.class, Serializable.class, or Comparable.class values.

– Andreas
Mar 25 at 21:33






myList is a list of object instances, e.g. a List<Number> storing Integer, Double, BigDecimal, ... objects, such as 42, 3.14159, 3e9876, ... --- myList2 is a list of Class objects, i.e. a list of Integer.class, Number.class, Object.class, Serializable.class, or Comparable.class values.

– Andreas
Mar 25 at 21:33














I understand the difference between super and extends. I was just wondering where myList2 would be used.

– AsadSMalik
Mar 25 at 21:33





I understand the difference between super and extends. I was just wondering where myList2 would be used.

– AsadSMalik
Mar 25 at 21:33




1




1





I can't offhand think of a use for a list of class objects, but in general you use a Class object as a way to indicate type, or as a way to determine the properties of that type.

– another-dave
Mar 25 at 21:53





I can't offhand think of a use for a list of class objects, but in general you use a Class object as a way to indicate type, or as a way to determine the properties of that type.

– another-dave
Mar 25 at 21:53












2 Answers
2






active

oldest

votes


















1














The first one, 'myList' may contain integer values. Example: myList.add(200);



The second one, 'myList2' may contain classes of type integer. Example: myList2.add(Integer.class);






share|improve this answer























  • Ok so like you mentioned in the comments, if instead of Integer, I'm extending Number, then the second list could contain elements Integer, BigDecimal etc.

    – AsadSMalik
    Mar 25 at 21:34











  • The first list might also contain e.g. String values, because it might be a List<Object>. --- The second list can also store classes of other types, e.g. Number.class, Object.class, Serializable.class, and Comparable.class.

    – Andreas
    Mar 25 at 21:35



















0














The first list contains objects of Integer and its superclasses.

The second one contains class objects (or simply classes) of Integer and its superclasses, i.e:



Integer.class;
Number.class;


You can read more about the differences here: The difference between Classes, Objects, and Instances






share|improve this answer



























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55346644%2fdifference-between-list-super-t-and-listclass-super-t%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The first one, 'myList' may contain integer values. Example: myList.add(200);



    The second one, 'myList2' may contain classes of type integer. Example: myList2.add(Integer.class);






    share|improve this answer























    • Ok so like you mentioned in the comments, if instead of Integer, I'm extending Number, then the second list could contain elements Integer, BigDecimal etc.

      – AsadSMalik
      Mar 25 at 21:34











    • The first list might also contain e.g. String values, because it might be a List<Object>. --- The second list can also store classes of other types, e.g. Number.class, Object.class, Serializable.class, and Comparable.class.

      – Andreas
      Mar 25 at 21:35
















    1














    The first one, 'myList' may contain integer values. Example: myList.add(200);



    The second one, 'myList2' may contain classes of type integer. Example: myList2.add(Integer.class);






    share|improve this answer























    • Ok so like you mentioned in the comments, if instead of Integer, I'm extending Number, then the second list could contain elements Integer, BigDecimal etc.

      – AsadSMalik
      Mar 25 at 21:34











    • The first list might also contain e.g. String values, because it might be a List<Object>. --- The second list can also store classes of other types, e.g. Number.class, Object.class, Serializable.class, and Comparable.class.

      – Andreas
      Mar 25 at 21:35














    1












    1








    1







    The first one, 'myList' may contain integer values. Example: myList.add(200);



    The second one, 'myList2' may contain classes of type integer. Example: myList2.add(Integer.class);






    share|improve this answer













    The first one, 'myList' may contain integer values. Example: myList.add(200);



    The second one, 'myList2' may contain classes of type integer. Example: myList2.add(Integer.class);







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 25 at 21:33









    Andreas VoglAndreas Vogl

    7735 silver badges12 bronze badges




    7735 silver badges12 bronze badges












    • Ok so like you mentioned in the comments, if instead of Integer, I'm extending Number, then the second list could contain elements Integer, BigDecimal etc.

      – AsadSMalik
      Mar 25 at 21:34











    • The first list might also contain e.g. String values, because it might be a List<Object>. --- The second list can also store classes of other types, e.g. Number.class, Object.class, Serializable.class, and Comparable.class.

      – Andreas
      Mar 25 at 21:35


















    • Ok so like you mentioned in the comments, if instead of Integer, I'm extending Number, then the second list could contain elements Integer, BigDecimal etc.

      – AsadSMalik
      Mar 25 at 21:34











    • The first list might also contain e.g. String values, because it might be a List<Object>. --- The second list can also store classes of other types, e.g. Number.class, Object.class, Serializable.class, and Comparable.class.

      – Andreas
      Mar 25 at 21:35

















    Ok so like you mentioned in the comments, if instead of Integer, I'm extending Number, then the second list could contain elements Integer, BigDecimal etc.

    – AsadSMalik
    Mar 25 at 21:34





    Ok so like you mentioned in the comments, if instead of Integer, I'm extending Number, then the second list could contain elements Integer, BigDecimal etc.

    – AsadSMalik
    Mar 25 at 21:34













    The first list might also contain e.g. String values, because it might be a List<Object>. --- The second list can also store classes of other types, e.g. Number.class, Object.class, Serializable.class, and Comparable.class.

    – Andreas
    Mar 25 at 21:35






    The first list might also contain e.g. String values, because it might be a List<Object>. --- The second list can also store classes of other types, e.g. Number.class, Object.class, Serializable.class, and Comparable.class.

    – Andreas
    Mar 25 at 21:35














    0














    The first list contains objects of Integer and its superclasses.

    The second one contains class objects (or simply classes) of Integer and its superclasses, i.e:



    Integer.class;
    Number.class;


    You can read more about the differences here: The difference between Classes, Objects, and Instances






    share|improve this answer





























      0














      The first list contains objects of Integer and its superclasses.

      The second one contains class objects (or simply classes) of Integer and its superclasses, i.e:



      Integer.class;
      Number.class;


      You can read more about the differences here: The difference between Classes, Objects, and Instances






      share|improve this answer



























        0












        0








        0







        The first list contains objects of Integer and its superclasses.

        The second one contains class objects (or simply classes) of Integer and its superclasses, i.e:



        Integer.class;
        Number.class;


        You can read more about the differences here: The difference between Classes, Objects, and Instances






        share|improve this answer















        The first list contains objects of Integer and its superclasses.

        The second one contains class objects (or simply classes) of Integer and its superclasses, i.e:



        Integer.class;
        Number.class;


        You can read more about the differences here: The difference between Classes, Objects, and Instances







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 25 at 21:56

























        answered Mar 25 at 21:33









        Pavel SmirnovPavel Smirnov

        2,7692 gold badges9 silver badges18 bronze badges




        2,7692 gold badges9 silver badges18 bronze badges



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55346644%2fdifference-between-list-super-t-and-listclass-super-t%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript