小编Lis*_*ish的帖子

如何在TreeMap中打印所有值?

我有一个项目,我正在为我的Java类工作(很明显),我一定错过了关于如何与TreeMaps交互的讲座.我不知道我正在做什么这个部分,我没有从谷歌那里找到很多帮助.

对于程序中的第一种情况,我必须打印TreeMap的所有值.以下是我提供的代码以及我用它完成的工作.案件A的一切都是我的,但它不起作用.任何帮助,将不胜感激.

import java.util.Scanner;
import java.util.Set;
import java.util.Map;
import java.util.TreeMap;
import java.io.File;
import java.io.FileNotFoundException;

public class prog7 {
 public static void main(String args[])
 throws FileNotFoundException
 {
Scanner kb=new Scanner(System.in);

/*here, add code to declare and create a tree map*/
TreeMap treeMap = new TreeMap();

/*here, add code to declare a variable and
 let it be the key set of the map
 */
String key;

//temporary variables
String tempWord;
String tempDef;

//the following code reads data from the file glossary.txt
//and …
Run Code Online (Sandbox Code Playgroud)

java treemap

11
推荐指数
3
解决办法
5万
查看次数

标签 统计

java ×1

treemap ×1