user1290784
user1290784

Reputation: 3

Cannot understand Java class definition

I have a problem with some Java coding. I saw this coding while I'm studying Java and cannot understand it... Below are some examples:

public class interface Set<E>

public class SocreManager extends ValueSortedMap<String,Integer>

The things that i cannot understand is the things inside the <> (in this example E and String,Integer ) What this <> mean? I Googled and I still cannot find a answer.

Upvotes: -1

Views: 133

Answers (1)

dantuch
dantuch

Reputation: 9283

ClassA<ClassB> Stands for ClassA that is using generics - one of java features

public class interface Set

this means that Set will be somewhat related to some other type (E). Set is holder for some objects. If you declare it as Set<String> you can put there only Strings, or something casted to String. That's the use of <E> here.

public class SocreManager extends ValueSortedMap

SocreManager is wrapper for ValueSortedMap it can add some new methods to ValueSortedMap but it also can add noting to it, and be used only as class name beautifier. If you add none features to SocreManager, than you will have everything the same as in ValueSortedMap but with shorter and simpler name - SocreManager. But looking at this name tells me that I will contain something more then just methods from super class.

Upvotes: 1

Related Questions