java - Index out of bounds error -


I'm having trouble with my code. I can tell why I'm getting an index due to the error, this code Estimating 2 byte arrays to combine into one. "According to the list [status] = bytead [t]"; But I do not know what is wrong. These arrays are started at 200 byte size.

  scanner input = new scanner (System.in); System.out.println ("Enter a web address"); String net = input.nextLine (); String net [] = net. Split ("\\."); Byte [] Length = New Byte [200]; Byte [] bytead = new byte [200]; Int bytelength = byteAdd.length * 2; Byte [] list = new byte [200]; For (int i = 0; i & lt; nets.length; i ++) {length [i] = (byte) (double) (net [i]. Length ()); Println (length [i]); } (Int i = 0; i & lt; nets.length; i ++) {byteAdd = net [i] .getBytes (); } Int position = 0, max = 0; For (int i = 0; i & lt; bytelength; i ++) {list [position] = length [i]; Status ++; For (int t = 0; t   

Is this stacktrace?

" main "java.lang Exception in the ArrayIndexOutOfBoundsException thread: error is on test.test.main (test.java:51)

This line is list [status] = bytead [T] on

your list = new byte [200]; size 200 List of

bytelength size 200 * 2 = 400

So when you say <

  for 
  (int i = 0; i & lt; bytelength; i ++)   

For A (int i = 0; i & lt; 400; i ++) // While all the arrays are limited to 200 sizes and this is throwing exceptions!

Therefore, your pay scale In the indicator, position ++ , this value runs up to 399, while the size of the array is 200

list [status] goes to list [200-400] / 200 should be deducted

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -