Linked Questions
31 questions linked to/from Java Generics: List, List<Object>, List<?>
15
votes
2
answers
15k
views
In java what's the difference between ?, E, T [duplicate]
Possible Duplicate:
Java Generics
Hi,
Can anyone please explain the difference of the three and each proper usage?
Thanks, been googling but I'm still confused on how to use each.
czetsuya
5
votes
6
answers
951
views
What does <?> stand for in Java? [duplicate]
Possible Duplicate:
Java Generics
In Eclipse, I am given warnings for using 'rawtypes' and one of it's fixes is to add <?>. For example:
Class parameter = String.class;
//Eclipse ...
2
votes
5
answers
337
views
What is the role of the data types inside of < > in Java? [duplicate]
Possible Duplicate:
Java Generics
To be more specific, whats the role of the <String> in the following line of code?
private List<String> item = new ArrayList<String>();
0
votes
4
answers
123
views
Syntax meaning of '< >' in Java [duplicate]
I am manipulating some code and unfortunately I cannot understand this part of it:
public class InMemoryTreeStateManager<T> implements TreeStateManager<T>
What is the meaning of <T>....
-1
votes
10
answers
168
views
what is "<>" use for in java? for example List<File> sourceFileList = new ArrayList<File> [duplicate]
I am new to java.
I would like to know what is <> used for in java.
This is an example where I get confused:
List<File> sourceFileList = new ArrayList<File>
1
vote
0
answers
274
views
Why can't I use different generic Lists with Java record constructors [duplicate]
According to JEP 395 a record with additional constructors can be used:
public record Aliases(List<String> value) {
public Aliases(Integer raw) {
this(List.of(raw.toString()));
...
-3
votes
1
answer
64
views
Defining Linked list in Java [duplicate]
private List<Manufacturer> productManufacturer = new LinkedList<Manufacturer>();
I am not able to understand why <> this symbol is here and Manufacturer inside it to define a ...
-2
votes
1
answer
82
views
What is a <T> object in Java? [duplicate]
I am hoping somebody can explain to me what a <T> object is, just a little confused on what it is/what it contains. Thank you
0
votes
1
answer
59
views
Why a generic like Node<Item> instead of a regular Node [duplicate]
I'm taking Algorithms I on coursera and came across the implementation of a Data Structure called Bag.
http://algs4.cs.princeton.edu/13stacks/Bag.java.html
However I don't undertand why the use a ...
0
votes
0
answers
54
views
Difference between ArrayAdapter<String> adapter and ArrayAdapter adapter? [duplicate]
If I use ArrayAdapter or ArrayAdapter<String>, it does not affect my code.
For example, if I write it like:
ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout....
209
votes
10
answers
185k
views
Difference between List, List<?>, List<T>, List<E>, and List<Object>
What are the differences between List, List<?>, List<T>, List<E>, and List<Object>?
1. List
List: is a raw type, therefore not typesafe. It will only generate a runtime error ...
92
votes
6
answers
211k
views
Java generics: multiple generic parameters?
I was wondering if it's possible to write a function that accepts multiple generic types as follows:
public int void myfunction(Set<T> a, Set<T> b) {
return 5;
}
Set<Integer> ...
51
votes
3
answers
46k
views
What are Generics in Java? [closed]
I don't really understand the point of generics. What do they do, how do you use them?
From what I can tell, all they do is check return types at compile times instead of run times to avoid running ...
15
votes
6
answers
8k
views
List vs List<Object>
Why do we lose type safety when using List and not while using List<Object>? Aren't they basically the same thing?
EDIT: I found that the following gives a compilation error
public class ...
3
votes
3
answers
2k
views
Java Generics? [closed]
Over the years I seen many people use the word "generics", I honestly have not a clue what it means, whatever it is I most likely use it but just don't know that it was called that. :p