Java - What is the sense of: List unmodifiableList(List list) [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • Understanding upper and lower bounds on ? in Java Generics

    5 answers



  • Generic type parameter naming convention for Java (with multiple chars)?

    5 answers




This is a static method from the Collections class. The type argument "? extends T" is bounded, in particular it has an upper bound represented by the type variable T which identifies the generic's method one and only type parameter which is implicitly bounded by the type Object.



However, I do not know what the point of writing "? extends T" compared to "?" is, since the type parameter is never replaced by a type argument?










share|improve this question













marked as duplicate by Makoto java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 18:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • The List<T> probably wants to deal with a specific kind of object. Having a <? extends T> would allow the class to narrow down what it will work with. <? extends T> is the difference between me creating a List<String>, and being able to Add() an int as an element. Because of <? extends String> would fail on an int, it won't allow me to add it, a good thing of course.
    – Frontear
    Nov 20 at 17:57












  • Thanks, but that was not the question. The question is what's the difference between "? extends T" and "?" whereby T just refers to the type parameter of the generic method.
    – chipsmonster91
    Nov 20 at 18:02










  • ? will allow for anything to pass through. ? extends T will allow only Objects that are either of type T, or extend type T to pass through.
    – Frontear
    Nov 20 at 18:03






  • 1




    List<?> would allow this to compile: List<String> list = Collections.unmodifiableList(Arrays.asList(1, 2, 3));
    – shmosel
    Nov 20 at 18:08






  • 1




    It's defined right there at the beginning. What are you saying?
    – shmosel
    Nov 20 at 18:40















up vote
0
down vote

favorite













This question already has an answer here:




  • Understanding upper and lower bounds on ? in Java Generics

    5 answers



  • Generic type parameter naming convention for Java (with multiple chars)?

    5 answers




This is a static method from the Collections class. The type argument "? extends T" is bounded, in particular it has an upper bound represented by the type variable T which identifies the generic's method one and only type parameter which is implicitly bounded by the type Object.



However, I do not know what the point of writing "? extends T" compared to "?" is, since the type parameter is never replaced by a type argument?










share|improve this question













marked as duplicate by Makoto java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 18:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • The List<T> probably wants to deal with a specific kind of object. Having a <? extends T> would allow the class to narrow down what it will work with. <? extends T> is the difference between me creating a List<String>, and being able to Add() an int as an element. Because of <? extends String> would fail on an int, it won't allow me to add it, a good thing of course.
    – Frontear
    Nov 20 at 17:57












  • Thanks, but that was not the question. The question is what's the difference between "? extends T" and "?" whereby T just refers to the type parameter of the generic method.
    – chipsmonster91
    Nov 20 at 18:02










  • ? will allow for anything to pass through. ? extends T will allow only Objects that are either of type T, or extend type T to pass through.
    – Frontear
    Nov 20 at 18:03






  • 1




    List<?> would allow this to compile: List<String> list = Collections.unmodifiableList(Arrays.asList(1, 2, 3));
    – shmosel
    Nov 20 at 18:08






  • 1




    It's defined right there at the beginning. What are you saying?
    – shmosel
    Nov 20 at 18:40













up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:




  • Understanding upper and lower bounds on ? in Java Generics

    5 answers



  • Generic type parameter naming convention for Java (with multiple chars)?

    5 answers




This is a static method from the Collections class. The type argument "? extends T" is bounded, in particular it has an upper bound represented by the type variable T which identifies the generic's method one and only type parameter which is implicitly bounded by the type Object.



However, I do not know what the point of writing "? extends T" compared to "?" is, since the type parameter is never replaced by a type argument?










share|improve this question














This question already has an answer here:




  • Understanding upper and lower bounds on ? in Java Generics

    5 answers



  • Generic type parameter naming convention for Java (with multiple chars)?

    5 answers




This is a static method from the Collections class. The type argument "? extends T" is bounded, in particular it has an upper bound represented by the type variable T which identifies the generic's method one and only type parameter which is implicitly bounded by the type Object.



However, I do not know what the point of writing "? extends T" compared to "?" is, since the type parameter is never replaced by a type argument?





This question already has an answer here:




  • Understanding upper and lower bounds on ? in Java Generics

    5 answers



  • Generic type parameter naming convention for Java (with multiple chars)?

    5 answers








java generics type-parameter generic-type-argument






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 17:56









chipsmonster91

6




6




marked as duplicate by Makoto java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 18:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Makoto java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 18:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • The List<T> probably wants to deal with a specific kind of object. Having a <? extends T> would allow the class to narrow down what it will work with. <? extends T> is the difference between me creating a List<String>, and being able to Add() an int as an element. Because of <? extends String> would fail on an int, it won't allow me to add it, a good thing of course.
    – Frontear
    Nov 20 at 17:57












  • Thanks, but that was not the question. The question is what's the difference between "? extends T" and "?" whereby T just refers to the type parameter of the generic method.
    – chipsmonster91
    Nov 20 at 18:02










  • ? will allow for anything to pass through. ? extends T will allow only Objects that are either of type T, or extend type T to pass through.
    – Frontear
    Nov 20 at 18:03






  • 1




    List<?> would allow this to compile: List<String> list = Collections.unmodifiableList(Arrays.asList(1, 2, 3));
    – shmosel
    Nov 20 at 18:08






  • 1




    It's defined right there at the beginning. What are you saying?
    – shmosel
    Nov 20 at 18:40


















  • The List<T> probably wants to deal with a specific kind of object. Having a <? extends T> would allow the class to narrow down what it will work with. <? extends T> is the difference between me creating a List<String>, and being able to Add() an int as an element. Because of <? extends String> would fail on an int, it won't allow me to add it, a good thing of course.
    – Frontear
    Nov 20 at 17:57












  • Thanks, but that was not the question. The question is what's the difference between "? extends T" and "?" whereby T just refers to the type parameter of the generic method.
    – chipsmonster91
    Nov 20 at 18:02










  • ? will allow for anything to pass through. ? extends T will allow only Objects that are either of type T, or extend type T to pass through.
    – Frontear
    Nov 20 at 18:03






  • 1




    List<?> would allow this to compile: List<String> list = Collections.unmodifiableList(Arrays.asList(1, 2, 3));
    – shmosel
    Nov 20 at 18:08






  • 1




    It's defined right there at the beginning. What are you saying?
    – shmosel
    Nov 20 at 18:40
















The List<T> probably wants to deal with a specific kind of object. Having a <? extends T> would allow the class to narrow down what it will work with. <? extends T> is the difference between me creating a List<String>, and being able to Add() an int as an element. Because of <? extends String> would fail on an int, it won't allow me to add it, a good thing of course.
– Frontear
Nov 20 at 17:57






The List<T> probably wants to deal with a specific kind of object. Having a <? extends T> would allow the class to narrow down what it will work with. <? extends T> is the difference between me creating a List<String>, and being able to Add() an int as an element. Because of <? extends String> would fail on an int, it won't allow me to add it, a good thing of course.
– Frontear
Nov 20 at 17:57














Thanks, but that was not the question. The question is what's the difference between "? extends T" and "?" whereby T just refers to the type parameter of the generic method.
– chipsmonster91
Nov 20 at 18:02




Thanks, but that was not the question. The question is what's the difference between "? extends T" and "?" whereby T just refers to the type parameter of the generic method.
– chipsmonster91
Nov 20 at 18:02












? will allow for anything to pass through. ? extends T will allow only Objects that are either of type T, or extend type T to pass through.
– Frontear
Nov 20 at 18:03




? will allow for anything to pass through. ? extends T will allow only Objects that are either of type T, or extend type T to pass through.
– Frontear
Nov 20 at 18:03




1




1




List<?> would allow this to compile: List<String> list = Collections.unmodifiableList(Arrays.asList(1, 2, 3));
– shmosel
Nov 20 at 18:08




List<?> would allow this to compile: List<String> list = Collections.unmodifiableList(Arrays.asList(1, 2, 3));
– shmosel
Nov 20 at 18:08




1




1




It's defined right there at the beginning. What are you saying?
– shmosel
Nov 20 at 18:40




It's defined right there at the beginning. What are you saying?
– shmosel
Nov 20 at 18:40

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'