这个Java语法是什么意思? [英] What does this Java Syntax mean?

查看:199
本文介绍了这个Java语法是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

什么是< TYPE>在java中是什么意思?


在下面的代码中,Iterator < V> 和OutputCollector < K,V> 是指?它是一种特殊的数据类型吗?

pre $ $ $ $ $ $ $ $ $ b OutputCollector< K,V>输出,
Reporter记者)抛出IOException {


解决方案

K代表Key和V,代表HashMap中的值。没有必须实例化或子类化的Key类或Value类,这是泛型的语义。这些字母只是您决定填补关键和价值角色的任何类别的占位符。

Possible Duplicate:
What does the <TYPE> in java mean?

In the code below, what does Iterator<V> and OutputCollector<K, V> mean? Is it a special data type?

public void reduce(K key, 
  Iterator<V> values, 
  OutputCollector<K, V> output, 
  Reporter reporter) throws IOException {

解决方案

K stands for Key and V for Value, like in a HashMap. There isn't a Key class or a Value class that you have to instantiate or subclass, it's a semantic thing for generics. Those letters are only placeholders for whatever classes you decide should fill the Key and Value roles.

这篇关于这个Java语法是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆