java - 当我为数组赋值时它显示不兼容的数据类型
问题描述
我遇到不兼容的数据类型错误。我该怎么做才能删除它。我在将值分配给 tt1 的最后一行的 [getsubject] 处收到错误。它表明 getsubject 是不兼容的类型。
//FOR TIMETABLE 1
String[][] tt1=new String[10][10];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_entry);
final EditText subject=(EditText)findViewById(R.id.subject);
final EditText professor=(EditText)findViewById(R.id.professor);
add=(Button)findViewById(R.id.add_button);
add.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
//Adding and Displaying subjects
String getsubject=subject.getText().toString();
String getprofessor=professor.getText().toString();
tt1[getsubject][getprofessor]=scan.next();
}
});
解决方案
您应该使用int
value 来访问数组项,但您使用String
.
推荐阅读
- c# - moq 存储库如何测试 Iqueryable 依赖项
- php - 标题 X-Frame-Options SAMEORIGIN 不起作用
- javascript - 检查对象中的每个条目是否不为空或未定义的智能方法
- vba - 如何使用宏在 Word 中自动查找特定文本并将其格式化为小型大写字母?
- laravel - GROUP BY laravel 中的关系数据
- asp.net-core - 如何在 .net 核心中使用 DelegatingHandler 从 asp.net 核心中的响应中删除属性?
- javascript - 未捕获的类型错误:无法访问属性“追加”,cartItems 未定义
- flutter - 在颤动中从另一个文件导入字符串列表
- python - 如果满足条件,您可以使两列相等吗
- php - 如何将刀片文件中的集合或数组传递给laravel中的控制器?