What does (angle brackets) mean in Java?
up vote
100
down vote
favorite
I am currently studying Java and have recently been stumped by angle brackets(<>). What exactly do they mean?
public class Pool<T>{
public interface PoolFactory<T>{
public T createObject();
}
this.freeObjects= new ArrayList<T>(maxsize)
}
What does the <T>
mean? Does it means that I can create an object of type T
?
java generics
add a comment |
up vote
100
down vote
favorite
I am currently studying Java and have recently been stumped by angle brackets(<>). What exactly do they mean?
public class Pool<T>{
public interface PoolFactory<T>{
public T createObject();
}
this.freeObjects= new ArrayList<T>(maxsize)
}
What does the <T>
mean? Does it means that I can create an object of type T
?
java generics
11
google java generics
– jcomeau_ictx
Jul 7 '11 at 8:04
4
I'm finding it hard to parse your code. There's no indentation for a start, and there are two open braces and only one close. IsT createObject
supposed to be inside Pool or PoolFactory? Where isthis.freeObjects = ...
supposed to be? Is that a separate example? It is illegal to have it there; it has to be inside a method.
– mgiuca
Jul 7 '11 at 8:17
If someone is looking for information about<>
(diamond operator) which could be used likeList<Integer> list = new ArrayList<>();
visit docs.oracle.com/javase/7/docs/technotes/guides/language/….
– Pshemo
Mar 1 at 17:21
add a comment |
up vote
100
down vote
favorite
up vote
100
down vote
favorite
I am currently studying Java and have recently been stumped by angle brackets(<>). What exactly do they mean?
public class Pool<T>{
public interface PoolFactory<T>{
public T createObject();
}
this.freeObjects= new ArrayList<T>(maxsize)
}
What does the <T>
mean? Does it means that I can create an object of type T
?
java generics
I am currently studying Java and have recently been stumped by angle brackets(<>). What exactly do they mean?
public class Pool<T>{
public interface PoolFactory<T>{
public T createObject();
}
this.freeObjects= new ArrayList<T>(maxsize)
}
What does the <T>
mean? Does it means that I can create an object of type T
?
java generics
java generics
edited Mar 1 at 17:18
Pshemo
93.2k14129183
93.2k14129183
asked Jul 7 '11 at 8:03
Laughy
66951320
66951320
11
google java generics
– jcomeau_ictx
Jul 7 '11 at 8:04
4
I'm finding it hard to parse your code. There's no indentation for a start, and there are two open braces and only one close. IsT createObject
supposed to be inside Pool or PoolFactory? Where isthis.freeObjects = ...
supposed to be? Is that a separate example? It is illegal to have it there; it has to be inside a method.
– mgiuca
Jul 7 '11 at 8:17
If someone is looking for information about<>
(diamond operator) which could be used likeList<Integer> list = new ArrayList<>();
visit docs.oracle.com/javase/7/docs/technotes/guides/language/….
– Pshemo
Mar 1 at 17:21
add a comment |
11
google java generics
– jcomeau_ictx
Jul 7 '11 at 8:04
4
I'm finding it hard to parse your code. There's no indentation for a start, and there are two open braces and only one close. IsT createObject
supposed to be inside Pool or PoolFactory? Where isthis.freeObjects = ...
supposed to be? Is that a separate example? It is illegal to have it there; it has to be inside a method.
– mgiuca
Jul 7 '11 at 8:17
If someone is looking for information about<>
(diamond operator) which could be used likeList<Integer> list = new ArrayList<>();
visit docs.oracle.com/javase/7/docs/technotes/guides/language/….
– Pshemo
Mar 1 at 17:21
11
11
google java generics
– jcomeau_ictx
Jul 7 '11 at 8:04
google java generics
– jcomeau_ictx
Jul 7 '11 at 8:04
4
4
I'm finding it hard to parse your code. There's no indentation for a start, and there are two open braces and only one close. Is
T createObject
supposed to be inside Pool or PoolFactory? Where is this.freeObjects = ...
supposed to be? Is that a separate example? It is illegal to have it there; it has to be inside a method.– mgiuca
Jul 7 '11 at 8:17
I'm finding it hard to parse your code. There's no indentation for a start, and there are two open braces and only one close. Is
T createObject
supposed to be inside Pool or PoolFactory? Where is this.freeObjects = ...
supposed to be? Is that a separate example? It is illegal to have it there; it has to be inside a method.– mgiuca
Jul 7 '11 at 8:17
If someone is looking for information about
<>
(diamond operator) which could be used like List<Integer> list = new ArrayList<>();
visit docs.oracle.com/javase/7/docs/technotes/guides/language/….– Pshemo
Mar 1 at 17:21
If someone is looking for information about
<>
(diamond operator) which could be used like List<Integer> list = new ArrayList<>();
visit docs.oracle.com/javase/7/docs/technotes/guides/language/….– Pshemo
Mar 1 at 17:21
add a comment |
6 Answers
6
active
oldest
votes
up vote
115
down vote
<T>
is a generic and can usually be read as "of type T". It depends on the type to the left of the <> what it actually means.
I don't know what a Pool
or PoolFactory
is, but you also mention ArrayList<T>
, which is a standard Java class, so I'll talk to that.
Usually, you won't see "T" in there, you'll see another type. So if you see ArrayList<Integer>
for example, that means "An ArrayList
of Integer
s." Many classes use generics to constrain the type of the elements in a container, for example. Another example is HashMap<String, Integer>
, which means "a map with String
keys and Integer
values."
Your Pool example is a bit different, because there you are defining a class. So in that case, you are creating a class that somebody else could instantiate with a particular type in place of T. For example, I could create an object of type Pool<String>
using your class definition. That would mean two things:
- My
Pool<String>
would have an interfacePoolFactory<String>
with acreateObject
method that returnsString
s. - Internally, the
Pool<String>
would contain anArrayList
of Strings.
This is great news, because at another time, I could come along and create a Pool<Integer>
which would use the same code, but have Integer
wherever you see T
in the source.
add a comment |
up vote
20
down vote
It is related to generics in java. If I mentioned ArrayList<String>
that means I can add only String type object to that ArrayList.
The two major benefits of generics in Java are:
- Reducing the number of casts in your program, thus reducing the number of potential bugs in your program.
- Improving code clarity
add a comment |
up vote
16
down vote
It's really simple. It's a new feature introduced in J2SE 5. Specifying angular brackets after the class name means you are creating a temporary data type which can hold any type of data.
Example:
class A<T>{
T obj;
void add(T obj){
this.obj=obj;
}
T get(){
return obj;
}
}
public class generics {
static<E> void print(E elements){
for(E element:elements){
System.out.println(element);
}
}
public static void main(String args) {
A<String> obj=new A<String>();
A<Integer> obj1=new A<Integer>();
obj.add("hello");
obj1.add(6);
System.out.println(obj.get());
System.out.println(obj1.get());
Integer arr={1,3,5,7};
print(arr);
}
}
Instead of <T>
, you can actually write anything and it will work the same way. Try writing <ABC>
in place of <T>
.
This is just for convenience:
<T>
is referred to as any type
<E>
as element type
<N>
as number type
<V>
as value
<K>
as key
But you can name it anything you want, it doesn't really matter.
Moreover, Integer
, String
, Boolean
etc are wrapper classes of Java which help in checking of types during compilation. For example, in the above code, obj
is of type String
, so you can't add any other type to it (try obj.add(1)
, it will cast an error). Similarly, obj1
is of the Integer
type, you can't add any other type to it (try obj1.add("hello")
, error will be there).
add a comment |
up vote
8
down vote
is called a generic type. You can instantiate an object Pool like this:
PoolFactory<Integer> pool = new Pool<Integer>();
The generic parameter can only be a reference type. So you can't use primitive types like int or double or char or other primitive types.
add a comment |
up vote
6
down vote
<>
is used to indicate generics in Java.
T
is a type parameter in this example. And no: instantiating is one of the few things that you can't do with T
.
Apart from the tutorial linked above Angelika Langers Generics FAQ is a great resource on the topic.
add a comment |
up vote
4
down vote
Generic classes are a type of class that takes in a data type as a parameter when it's created. This type parameter is specified using angle brackets and the type can change each time a new instance of the class is instantiated. For instance, let's create an ArrayList for Employee objects and another for Company objects
ArrayList<Employee> employees = new ArrayList<Employee>();
ArrayList<Company> companies = new ArrayList<Company>();
You'll notice that we're using the same ArrayList class to create both lists and we pass in the Employee or Company type using angle brackets. Having one generic class be able to handle multiple types of data cuts down on having a lot of classes that perform similar tasks.
Generics also help to cut down on bugs by giving everything a strong type which helps the compiler point out errors. By specifying a type for ArrayList, the compiler will throw an error if you try to add an Employee to the Company list or vice versa.
add a comment |
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
115
down vote
<T>
is a generic and can usually be read as "of type T". It depends on the type to the left of the <> what it actually means.
I don't know what a Pool
or PoolFactory
is, but you also mention ArrayList<T>
, which is a standard Java class, so I'll talk to that.
Usually, you won't see "T" in there, you'll see another type. So if you see ArrayList<Integer>
for example, that means "An ArrayList
of Integer
s." Many classes use generics to constrain the type of the elements in a container, for example. Another example is HashMap<String, Integer>
, which means "a map with String
keys and Integer
values."
Your Pool example is a bit different, because there you are defining a class. So in that case, you are creating a class that somebody else could instantiate with a particular type in place of T. For example, I could create an object of type Pool<String>
using your class definition. That would mean two things:
- My
Pool<String>
would have an interfacePoolFactory<String>
with acreateObject
method that returnsString
s. - Internally, the
Pool<String>
would contain anArrayList
of Strings.
This is great news, because at another time, I could come along and create a Pool<Integer>
which would use the same code, but have Integer
wherever you see T
in the source.
add a comment |
up vote
115
down vote
<T>
is a generic and can usually be read as "of type T". It depends on the type to the left of the <> what it actually means.
I don't know what a Pool
or PoolFactory
is, but you also mention ArrayList<T>
, which is a standard Java class, so I'll talk to that.
Usually, you won't see "T" in there, you'll see another type. So if you see ArrayList<Integer>
for example, that means "An ArrayList
of Integer
s." Many classes use generics to constrain the type of the elements in a container, for example. Another example is HashMap<String, Integer>
, which means "a map with String
keys and Integer
values."
Your Pool example is a bit different, because there you are defining a class. So in that case, you are creating a class that somebody else could instantiate with a particular type in place of T. For example, I could create an object of type Pool<String>
using your class definition. That would mean two things:
- My
Pool<String>
would have an interfacePoolFactory<String>
with acreateObject
method that returnsString
s. - Internally, the
Pool<String>
would contain anArrayList
of Strings.
This is great news, because at another time, I could come along and create a Pool<Integer>
which would use the same code, but have Integer
wherever you see T
in the source.
add a comment |
up vote
115
down vote
up vote
115
down vote
<T>
is a generic and can usually be read as "of type T". It depends on the type to the left of the <> what it actually means.
I don't know what a Pool
or PoolFactory
is, but you also mention ArrayList<T>
, which is a standard Java class, so I'll talk to that.
Usually, you won't see "T" in there, you'll see another type. So if you see ArrayList<Integer>
for example, that means "An ArrayList
of Integer
s." Many classes use generics to constrain the type of the elements in a container, for example. Another example is HashMap<String, Integer>
, which means "a map with String
keys and Integer
values."
Your Pool example is a bit different, because there you are defining a class. So in that case, you are creating a class that somebody else could instantiate with a particular type in place of T. For example, I could create an object of type Pool<String>
using your class definition. That would mean two things:
- My
Pool<String>
would have an interfacePoolFactory<String>
with acreateObject
method that returnsString
s. - Internally, the
Pool<String>
would contain anArrayList
of Strings.
This is great news, because at another time, I could come along and create a Pool<Integer>
which would use the same code, but have Integer
wherever you see T
in the source.
<T>
is a generic and can usually be read as "of type T". It depends on the type to the left of the <> what it actually means.
I don't know what a Pool
or PoolFactory
is, but you also mention ArrayList<T>
, which is a standard Java class, so I'll talk to that.
Usually, you won't see "T" in there, you'll see another type. So if you see ArrayList<Integer>
for example, that means "An ArrayList
of Integer
s." Many classes use generics to constrain the type of the elements in a container, for example. Another example is HashMap<String, Integer>
, which means "a map with String
keys and Integer
values."
Your Pool example is a bit different, because there you are defining a class. So in that case, you are creating a class that somebody else could instantiate with a particular type in place of T. For example, I could create an object of type Pool<String>
using your class definition. That would mean two things:
- My
Pool<String>
would have an interfacePoolFactory<String>
with acreateObject
method that returnsString
s. - Internally, the
Pool<String>
would contain anArrayList
of Strings.
This is great news, because at another time, I could come along and create a Pool<Integer>
which would use the same code, but have Integer
wherever you see T
in the source.
answered Jul 7 '11 at 8:12
mgiuca
16.4k54466
16.4k54466
add a comment |
add a comment |
up vote
20
down vote
It is related to generics in java. If I mentioned ArrayList<String>
that means I can add only String type object to that ArrayList.
The two major benefits of generics in Java are:
- Reducing the number of casts in your program, thus reducing the number of potential bugs in your program.
- Improving code clarity
add a comment |
up vote
20
down vote
It is related to generics in java. If I mentioned ArrayList<String>
that means I can add only String type object to that ArrayList.
The two major benefits of generics in Java are:
- Reducing the number of casts in your program, thus reducing the number of potential bugs in your program.
- Improving code clarity
add a comment |
up vote
20
down vote
up vote
20
down vote
It is related to generics in java. If I mentioned ArrayList<String>
that means I can add only String type object to that ArrayList.
The two major benefits of generics in Java are:
- Reducing the number of casts in your program, thus reducing the number of potential bugs in your program.
- Improving code clarity
It is related to generics in java. If I mentioned ArrayList<String>
that means I can add only String type object to that ArrayList.
The two major benefits of generics in Java are:
- Reducing the number of casts in your program, thus reducing the number of potential bugs in your program.
- Improving code clarity
edited Aug 20 '13 at 1:12
Paul Bellora
45k15111161
45k15111161
answered Jul 7 '11 at 9:39
user831722
add a comment |
add a comment |
up vote
16
down vote
It's really simple. It's a new feature introduced in J2SE 5. Specifying angular brackets after the class name means you are creating a temporary data type which can hold any type of data.
Example:
class A<T>{
T obj;
void add(T obj){
this.obj=obj;
}
T get(){
return obj;
}
}
public class generics {
static<E> void print(E elements){
for(E element:elements){
System.out.println(element);
}
}
public static void main(String args) {
A<String> obj=new A<String>();
A<Integer> obj1=new A<Integer>();
obj.add("hello");
obj1.add(6);
System.out.println(obj.get());
System.out.println(obj1.get());
Integer arr={1,3,5,7};
print(arr);
}
}
Instead of <T>
, you can actually write anything and it will work the same way. Try writing <ABC>
in place of <T>
.
This is just for convenience:
<T>
is referred to as any type
<E>
as element type
<N>
as number type
<V>
as value
<K>
as key
But you can name it anything you want, it doesn't really matter.
Moreover, Integer
, String
, Boolean
etc are wrapper classes of Java which help in checking of types during compilation. For example, in the above code, obj
is of type String
, so you can't add any other type to it (try obj.add(1)
, it will cast an error). Similarly, obj1
is of the Integer
type, you can't add any other type to it (try obj1.add("hello")
, error will be there).
add a comment |
up vote
16
down vote
It's really simple. It's a new feature introduced in J2SE 5. Specifying angular brackets after the class name means you are creating a temporary data type which can hold any type of data.
Example:
class A<T>{
T obj;
void add(T obj){
this.obj=obj;
}
T get(){
return obj;
}
}
public class generics {
static<E> void print(E elements){
for(E element:elements){
System.out.println(element);
}
}
public static void main(String args) {
A<String> obj=new A<String>();
A<Integer> obj1=new A<Integer>();
obj.add("hello");
obj1.add(6);
System.out.println(obj.get());
System.out.println(obj1.get());
Integer arr={1,3,5,7};
print(arr);
}
}
Instead of <T>
, you can actually write anything and it will work the same way. Try writing <ABC>
in place of <T>
.
This is just for convenience:
<T>
is referred to as any type
<E>
as element type
<N>
as number type
<V>
as value
<K>
as key
But you can name it anything you want, it doesn't really matter.
Moreover, Integer
, String
, Boolean
etc are wrapper classes of Java which help in checking of types during compilation. For example, in the above code, obj
is of type String
, so you can't add any other type to it (try obj.add(1)
, it will cast an error). Similarly, obj1
is of the Integer
type, you can't add any other type to it (try obj1.add("hello")
, error will be there).
add a comment |
up vote
16
down vote
up vote
16
down vote
It's really simple. It's a new feature introduced in J2SE 5. Specifying angular brackets after the class name means you are creating a temporary data type which can hold any type of data.
Example:
class A<T>{
T obj;
void add(T obj){
this.obj=obj;
}
T get(){
return obj;
}
}
public class generics {
static<E> void print(E elements){
for(E element:elements){
System.out.println(element);
}
}
public static void main(String args) {
A<String> obj=new A<String>();
A<Integer> obj1=new A<Integer>();
obj.add("hello");
obj1.add(6);
System.out.println(obj.get());
System.out.println(obj1.get());
Integer arr={1,3,5,7};
print(arr);
}
}
Instead of <T>
, you can actually write anything and it will work the same way. Try writing <ABC>
in place of <T>
.
This is just for convenience:
<T>
is referred to as any type
<E>
as element type
<N>
as number type
<V>
as value
<K>
as key
But you can name it anything you want, it doesn't really matter.
Moreover, Integer
, String
, Boolean
etc are wrapper classes of Java which help in checking of types during compilation. For example, in the above code, obj
is of type String
, so you can't add any other type to it (try obj.add(1)
, it will cast an error). Similarly, obj1
is of the Integer
type, you can't add any other type to it (try obj1.add("hello")
, error will be there).
It's really simple. It's a new feature introduced in J2SE 5. Specifying angular brackets after the class name means you are creating a temporary data type which can hold any type of data.
Example:
class A<T>{
T obj;
void add(T obj){
this.obj=obj;
}
T get(){
return obj;
}
}
public class generics {
static<E> void print(E elements){
for(E element:elements){
System.out.println(element);
}
}
public static void main(String args) {
A<String> obj=new A<String>();
A<Integer> obj1=new A<Integer>();
obj.add("hello");
obj1.add(6);
System.out.println(obj.get());
System.out.println(obj1.get());
Integer arr={1,3,5,7};
print(arr);
}
}
Instead of <T>
, you can actually write anything and it will work the same way. Try writing <ABC>
in place of <T>
.
This is just for convenience:
<T>
is referred to as any type
<E>
as element type
<N>
as number type
<V>
as value
<K>
as key
But you can name it anything you want, it doesn't really matter.
Moreover, Integer
, String
, Boolean
etc are wrapper classes of Java which help in checking of types during compilation. For example, in the above code, obj
is of type String
, so you can't add any other type to it (try obj.add(1)
, it will cast an error). Similarly, obj1
is of the Integer
type, you can't add any other type to it (try obj1.add("hello")
, error will be there).
edited Mar 9 '17 at 0:58
Pang
6,8301563101
6,8301563101
answered Jul 21 '16 at 11:25
Ruturaj Mohanty
16114
16114
add a comment |
add a comment |
up vote
8
down vote
is called a generic type. You can instantiate an object Pool like this:
PoolFactory<Integer> pool = new Pool<Integer>();
The generic parameter can only be a reference type. So you can't use primitive types like int or double or char or other primitive types.
add a comment |
up vote
8
down vote
is called a generic type. You can instantiate an object Pool like this:
PoolFactory<Integer> pool = new Pool<Integer>();
The generic parameter can only be a reference type. So you can't use primitive types like int or double or char or other primitive types.
add a comment |
up vote
8
down vote
up vote
8
down vote
is called a generic type. You can instantiate an object Pool like this:
PoolFactory<Integer> pool = new Pool<Integer>();
The generic parameter can only be a reference type. So you can't use primitive types like int or double or char or other primitive types.
is called a generic type. You can instantiate an object Pool like this:
PoolFactory<Integer> pool = new Pool<Integer>();
The generic parameter can only be a reference type. So you can't use primitive types like int or double or char or other primitive types.
answered Jul 7 '11 at 8:10
Rafiek
5501515
5501515
add a comment |
add a comment |
up vote
6
down vote
<>
is used to indicate generics in Java.
T
is a type parameter in this example. And no: instantiating is one of the few things that you can't do with T
.
Apart from the tutorial linked above Angelika Langers Generics FAQ is a great resource on the topic.
add a comment |
up vote
6
down vote
<>
is used to indicate generics in Java.
T
is a type parameter in this example. And no: instantiating is one of the few things that you can't do with T
.
Apart from the tutorial linked above Angelika Langers Generics FAQ is a great resource on the topic.
add a comment |
up vote
6
down vote
up vote
6
down vote
<>
is used to indicate generics in Java.
T
is a type parameter in this example. And no: instantiating is one of the few things that you can't do with T
.
Apart from the tutorial linked above Angelika Langers Generics FAQ is a great resource on the topic.
<>
is used to indicate generics in Java.
T
is a type parameter in this example. And no: instantiating is one of the few things that you can't do with T
.
Apart from the tutorial linked above Angelika Langers Generics FAQ is a great resource on the topic.
answered Jul 7 '11 at 8:06
Joachim Sauer
232k49480559
232k49480559
add a comment |
add a comment |
up vote
4
down vote
Generic classes are a type of class that takes in a data type as a parameter when it's created. This type parameter is specified using angle brackets and the type can change each time a new instance of the class is instantiated. For instance, let's create an ArrayList for Employee objects and another for Company objects
ArrayList<Employee> employees = new ArrayList<Employee>();
ArrayList<Company> companies = new ArrayList<Company>();
You'll notice that we're using the same ArrayList class to create both lists and we pass in the Employee or Company type using angle brackets. Having one generic class be able to handle multiple types of data cuts down on having a lot of classes that perform similar tasks.
Generics also help to cut down on bugs by giving everything a strong type which helps the compiler point out errors. By specifying a type for ArrayList, the compiler will throw an error if you try to add an Employee to the Company list or vice versa.
add a comment |
up vote
4
down vote
Generic classes are a type of class that takes in a data type as a parameter when it's created. This type parameter is specified using angle brackets and the type can change each time a new instance of the class is instantiated. For instance, let's create an ArrayList for Employee objects and another for Company objects
ArrayList<Employee> employees = new ArrayList<Employee>();
ArrayList<Company> companies = new ArrayList<Company>();
You'll notice that we're using the same ArrayList class to create both lists and we pass in the Employee or Company type using angle brackets. Having one generic class be able to handle multiple types of data cuts down on having a lot of classes that perform similar tasks.
Generics also help to cut down on bugs by giving everything a strong type which helps the compiler point out errors. By specifying a type for ArrayList, the compiler will throw an error if you try to add an Employee to the Company list or vice versa.
add a comment |
up vote
4
down vote
up vote
4
down vote
Generic classes are a type of class that takes in a data type as a parameter when it's created. This type parameter is specified using angle brackets and the type can change each time a new instance of the class is instantiated. For instance, let's create an ArrayList for Employee objects and another for Company objects
ArrayList<Employee> employees = new ArrayList<Employee>();
ArrayList<Company> companies = new ArrayList<Company>();
You'll notice that we're using the same ArrayList class to create both lists and we pass in the Employee or Company type using angle brackets. Having one generic class be able to handle multiple types of data cuts down on having a lot of classes that perform similar tasks.
Generics also help to cut down on bugs by giving everything a strong type which helps the compiler point out errors. By specifying a type for ArrayList, the compiler will throw an error if you try to add an Employee to the Company list or vice versa.
Generic classes are a type of class that takes in a data type as a parameter when it's created. This type parameter is specified using angle brackets and the type can change each time a new instance of the class is instantiated. For instance, let's create an ArrayList for Employee objects and another for Company objects
ArrayList<Employee> employees = new ArrayList<Employee>();
ArrayList<Company> companies = new ArrayList<Company>();
You'll notice that we're using the same ArrayList class to create both lists and we pass in the Employee or Company type using angle brackets. Having one generic class be able to handle multiple types of data cuts down on having a lot of classes that perform similar tasks.
Generics also help to cut down on bugs by giving everything a strong type which helps the compiler point out errors. By specifying a type for ArrayList, the compiler will throw an error if you try to add an Employee to the Company list or vice versa.
answered May 20 '16 at 11:18
Adiii
5,4363135
5,4363135
add a comment |
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6607550%2fwhat-does-t-angle-brackets-mean-in-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
11
google java generics
– jcomeau_ictx
Jul 7 '11 at 8:04
4
I'm finding it hard to parse your code. There's no indentation for a start, and there are two open braces and only one close. Is
T createObject
supposed to be inside Pool or PoolFactory? Where isthis.freeObjects = ...
supposed to be? Is that a separate example? It is illegal to have it there; it has to be inside a method.– mgiuca
Jul 7 '11 at 8:17
If someone is looking for information about
<>
(diamond operator) which could be used likeList<Integer> list = new ArrayList<>();
visit docs.oracle.com/javase/7/docs/technotes/guides/language/….– Pshemo
Mar 1 at 17:21