What do you think will happen here:
for ( int i = 0; i < Main.ipList.length; i++){ Main.ipList[i+1] = newIpGet.toString(); Main.write(Main.ipList[i]); }
when i == Main.ipList.length - 1 and you are trying to access Main.ipList[i + 1] , which is equal to Main.ipList[Main.ipList.length] ? This ensures that you get the exception you see.
You declare:
"I cannot change my ipList [] declaration, otherwise it will ruin my entire project."
Sometimes there are times when you just need to plunge and ruin everything, and it looks like one of them. If you need an extensible array, do not use an array, but rather an ArrayList<String> .
source share