0

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>. in this code?

2

4 Answers 4

3

It is generics, it takes some time getting familiar with. you can read more about it here: http://en.wikipedia.org/wiki/Generics_in_Java

Sign up to request clarification or add additional context in comments.

Comments

3

This is a generic. It means T can be any class, and you need to specify what type when you declare a variable of that type. Similar to C++ templates, if you're familiar with that.

Comments

1

<T> is a generic type. Basically TreeStateManager works with any class that you pass to it, and you can tell it what type of class that is by putting the class name into the braces.

1 Comment

It's the class in the original poster's question using the generic type in braces.
0

That's stating InMemoryTreeStateManager is a generic class.

If you would want to instantiate this object (without warnings of raw types) you'd have to give the class a type.

i.e.

InMemoryTreeStateManager<String> manager = new InMemoryTreeStateManager<String>(); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.