-8

Possible Duplicate:
What does Map<?, ?> mean in Java?
Java Generics - What is this syntax for?

I was wondering what does the notation < > does in Java, for example.

public static class Map extends MapReduceBase 
    implements Mapper<LongWritable, Text, Text, IntWritable>

I am not a java expert in any fashion. I hope you can provide some clear answer for the reasons behind using the < > notation.

Community
  • 1
  • 1
DevZer0
  • 13,433
  • 7
  • 27
  • 51
  • 10
    You might want to read that -> http://docs.oracle.com/javase/tutorial/java/generics/ – MByD Jan 18 '13 at 14:15
  • Look at: http://docs.oracle.com/javase/tutorial/java/generics/types.html – jco.owens Jan 18 '13 at 14:16
  • They are related to `Generic`. See: http://en.wikipedia.org/wiki/Generics_in_Java – Maroun Jan 18 '13 at 14:16
  • 1
    What directive is used to justify so many down votes for this sort of newbie question? – Eric Leschinski Jan 18 '13 at 14:18
  • 2
    @ downvoters: This isn't a particularly easy thing to search for... Sure, it would be covered by any intermediate Java tutorial, but still, seems rather harsh... – T.J. Crowder Jan 18 '13 at 14:19
  • 1
    @EricLeschinski Downvoting because a person using Hadoop Interface and don't know generics.. Not the hello world program... – Shashi Jan 18 '13 at 14:27
  • Your specific line of code is for a inner class, which uses `MapReduceBase` as base class and which implements `Mapper`. Mapper has multiple generic types defined, but this specific `Map` only implements the methods for the types `LongWritable, Text, Text, IntWritable`. The inner class is static, i.e. it cannot access fields of an instance of the outer class. – Maarten Bodewes Jan 18 '13 at 14:28
  • @ZEROMILE i learn java when java was 1.2 versions old and then i ran a 10 year career run with PHP. I just got back to Java and was reading some code and had a question. I belive SO is here to be helpful place for the dev community but natzis like the downvotes who jumping up and ego-tripping aint really helping the cause. What would it matter even if i pulled up some code from dalvikvm if the question is real why does it matter to others. – DevZer0 May 31 '13 at 08:13
  • @EricLeschinski Thanks for supportive comment, see my comment above for some explanation. This very first question of mine has cost me the ability to ask questions here. – DevZer0 May 31 '13 at 08:14
  • @DevZer0 https://www.google.co.in/search?q=java+generics The very first link and in 3rd page, you will find the meaning of <>. Just google it before posting a question for which answer already exists. – Shashi May 31 '13 at 08:21
  • @ZEROMILE my point is if i don't know the word generics how do i go search about it because < > stands for less than and greater than also. so i didn't figure out a best way to search – DevZer0 May 31 '13 at 09:12

1 Answers1

4

It denotes generics. Mapper is a generic and you're inheriting from Mapper<LongWritable, Text, Text, IntWritable>, which is that generic specialized for those types.

It's like Vector - also a generic - you can have Vector<Object> and Vector<SomeOtherClass>.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625