java - 为什么我的代码说找不到 . 象征?
问题描述
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);
^
解决方案
我假设您在这里使用 Java。Java Map 接口没有add
方法。而是使用该put(key, value)
方法将数据添加到地图。
通常,当编译器说它cannot find symbol
指向您错误地使用 API 时。这可能是拼写错误或误解。使用 API 文档来提供帮助。
推荐阅读
- sql-server - VBA Excel 中的存储过程未运行
- java - How to use OOP, constructors, and objects to pass variables to methods and main method
- sql - 更新匹配条件的json中的值
- cordova - IBM Worklight 7.1-无法使用window.open在android设备中使用本地保存的文件,获取异常为“android.os.FileUriExposedException:”
- spring - 在 Spring JPA 中配置事务尝试
- php - 设置while循环在没有值时返回一个值
- kubernetes - calico/node 未准备好:BIRD 未准备好:BGP 未建立
- css - Angular:根据用户加载 scss
- javascript - 将 Blob 传递给新音频
- opencv - 由于 Zbar 和 Xlib 中的 Window 对象定义不明确导致的编译错误