0

If I run this code without any changes, I get that error Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: -1

If I remove syntax of comment line System.out.println(data);, I don't get any error.

I don't want to print any situation of my app. Variable of data is important for me. How can I solve this problem without using System.out?

Could you help me?

private static ArrayList<String> myList = new ArrayList();
private BufferedReader in1;
private String[] s;
private String data;
...
...
...
...

while (close) {
            try {
                if ((data = in1.readLine()) != null) {
                    //System.out.println(data); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    if (data.contains("#")) {
                        s = data.split("#");
                        if (s[0].equals("enter")) {
                            if (s[1].equals("ok")) {
                            } else if (s[1].equals("no")) {
                            } else {
                                synchronized (myList) {
                                    myList.set(myList.indexOf(id), s[1]);
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                break;
            }
        }
Nickname
  • 39
  • 9

0 Answers0