是否支持Java关联数组? [英] Does Java support associative arrays?

查看:245
本文介绍了是否支持Java关联数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如果在Java数组可以做这样的事情:

I'm wondering if arrays in Java could do something like this:

int[] a = new int[10];
a["index0"] = 100;
a["index1"] = 100;

我知道我已经看到了在其他语言类似的功能,但我不是很熟悉的任何细节......只是,有很多方法可以用数值字符串常量,而不是单纯的数字指标相关联。有没有一种方法来实现在Java中这样的事情?

I know I've seen similar features in other languages, but I'm not really familiar with any specifics... Just that there are ways to associate values with string constants rather than mere numeric indexes. Is there a way to achieve such a thing in Java?

推荐答案

我不知道关于C ++的事情,但你可能寻找一个类实现的 Map接口。

I don't know a thing about C++, but you are probably looking for a Class implementing the Map interface.

这篇关于是否支持Java关联数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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