首页 > 解决方案 > 为什么我的代码说找不到 . 象征?

问题描述

 HashMap <String, Integer> output = new HashMap <String, Integer> (); 
 for (int j = 0 ; j < np; j++) { 
   output.add(people, recived1);
   System.out.println(output);

当我编译它说的代码时:

error: cannot find symbol
output.add(people, recived1);
      ^ 

标签: javacompiler-errors

解决方案


我假设您在这里使用 Java。Java Map 接口没有add方法。而是使用该put(key, value)方法将数据添加到地图。

通常,当编译器说它cannot find symbol指向您错误地使用 API 时。这可能是拼写错误或误解。使用 API 文档来提供帮助。


推荐阅读