首页 > 解决方案 > 当我为数组赋值时它显示不兼容的数据类型

问题描述

我遇到不兼容的数据类型错误。我该怎么做才能删除它。我在将值分配给 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();
        }
    });

标签: javaandroid

解决方案


您应该使用intvalue 来访问数组项,但您使用String.


推荐阅读