Java 未从数组中获取正确的值

Java 未从数组中获取正确的值,java,android,arrays,arraylist,settext,Java,Android,Arrays,Arraylist,Settext,我想定义一个数组,它将包含一组字符串 然后,我希望能够引用数组中的不同字符串。听起来很简单,但使用下面的代码,我将返回变量onOneClick的“to be”(即数组中的第二个字符串)(应该是指第一个字符串或“to indicative”) 有什么想法吗 String hintsList[] = {"to implicate", "to be", "to bite", "to draw", "to run", "to go", "to escape", "to fall", "to accept

我想定义一个数组,它将包含一组字符串

然后,我希望能够引用数组中的不同字符串。听起来很简单,但使用下面的代码,我将返回变量onOneClick的“to be”(即数组中的第二个字符串)(应该是指第一个字符串或“to indicative”)

有什么想法吗

String hintsList[] = {"to implicate", "to be", "to bite", "to draw", "to run", "to go", "to escape", "to fall", "to accept", "to open", "to laugh", "to listen", "to open", "to dance", "to use", "to save (not waste)", "to create"};

final String onOneClick = hintsList[1];
final EditText box0101 = (EditText)findViewById(R.id.box0101);

        box0101.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            txtHint.setText(onOneClick);                
        }
    });

数组从零开始索引。如果需要第一个元素,请使用
hintsList[0]

Java中的数组是从零开始的。您应该使用
最终字符串onOneClick=hintsList[0];

数组从索引0开始。CS101。