Я использую GUI, и каждый раз, когда пользователь вводит информацию, она не сохраняется в 2D-массив.
public String [][] arrayQues = new String[2][5];
textFieldAns = new JTextField();
textFieldAns.setBounds(127, 130, 272, 42);
textFieldAns.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String Ans = textFieldAns.getText();
textFieldAns.selectAll();
arrayQues[1][0] = Ans;
}
});
Я знаю, что она не сохраняется в 2D-массив, потому что в другой класс, который наследует вышеуказанный класс, метка randQ отображается как null
Random r = new Random();
int randAnswer = r.nextInt(arrayQues[1].length);
int randQuestion = r.nextInt(arrayQues[0].length);
String randQ = arrayQues[0][randQuestion];
String randA = arrayQues[1][randQuestion];
JLabel randomQuestion = new JLabel(randQ);
randomQuestion.setBounds(112, 61, 269, frame.getContentPane().add(randomQuestion);