「java语言字典」数据字典java

博主:adminadmin 2022-11-27 04:33:04 55

今天给各位分享java语言字典的知识,其中也会对数据字典java进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java字典怎么使用

Map可以实现类似数据库的功能。比如一个人的姓名和年龄信息你可以存在一个Map里面,就像这样: Map map = new HashMap(); map.put("张三", 40)

JAVA里面的dictionary怎么用; 举个简单的例子最好,

我是用C#语言的,字典的基本思路就是,键值对!每个键值对应一个值。

这一段C#代码你可以参考一下:我想对你有帮助

public class OthelloCast : Liststring

{

// Use a dictionary to contain

// cast names (key) and actor names (value).

public Dictionarystring, string OthelloDict =

new Dictionarystring, string();

public OthelloCast()

{

// Add data to the dictionary.

OthelloDict.Add("Bianca", "Gretchen Rivas");

OthelloDict.Add("Brabantio", "Carlos Lacerda");

OthelloDict.Add("Cassio", "Steve Masters");

OthelloDict.Add("Clown", "Michael Ludwig");

OthelloDict.Add("Desdemona", "Catherine Autier Miconi");

OthelloDict.Add("Duke of Venice", "Ken Circeo");

OthelloDict.Add("Emilia", "Eva Valverde");

OthelloDict.Add("Gratiano", "Akos Kozari");

OthelloDict.Add("Iago", "Darius Stasevicius");

OthelloDict.Add("Lodovico", "Fernando Souza");

OthelloDict.Add("Montano", "Jeff Hay");

OthelloDict.Add("Othello", "Marco Tanara");

OthelloDict.Add("Roderigo", "Pedro Ruivo");

// Populate the list with character names.

foreach (KeyValuePairstring, string kvp in OthelloDict)

{

this.Add(kvp.Key);

}

}

Java里面字典dictionary怎么定义

Dictionary对象用于存储数据关键字和条目对(即类似“key=value”的形式)。它可以存取任何形式的数据的条目。每个条目都与一个唯一的关键字相关联。该关键字用来检索单个条目,通常是整数或字符串,可以是除数组外的任何类型。

下面的代码举例说明了如何创建一个 Dictionary 对象:

Dim d '创建一个变量

Set d = CreateObject(Scripting.Dictionary)

d.Add "a", "Athens" '添加一些关键字和条目

d.Add "b", "Belgrade"

d.Add "c", "Cairo"

Dictionary常用的操作有Add(添加)、Remove(删除)、Exists(检查某个关键字是否在字典中);常用的属性有Item(key)(获取某个关键字对应的数据),等等。

差不多就有点象平时我们在算法中提到的HashTable吧。

关于java语言字典和数据字典java的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-11-27,除非注明,否则均为首码项目网原创文章,转载请注明出处。