| Author |
Convert 1d array to 2D boolean
|
Nattakan Lukkanapinit
Greenhorn
Joined: Apr 24, 2010
Posts: 16
|
|
I have a set of String and would like to convert to 2d array of boolean
I have an error at line 38 and 32.
This is my String
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26168
|
|
Nattakan Lukkanapinit wrote:I have an error at line 38 and 32.
What is the error?
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Nattakan Lukkanapinit
Greenhorn
Joined: Apr 24, 2010
Posts: 16
|
|
Jeanne Boyarsky wrote:
Nattakan Lukkanapinit wrote:I have an error at line 38 and 32.
What is the error?
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 13
at test.main(test.java:34)
|
 |
Sunil Kumar
Ranch Hand
Joined: Apr 24, 2007
Posts: 76
|
|
You have quiet a few problems here
Line 32 : You are iterating on the string array(of length 13) using the length of corresponding element of the array(38). Clearly, when you reach at 13 on str_data[z], it will throw ArrayIndexOutOfBounds
You can fix the above by using str_data.length, but your code piece wouldnt return the desired results. You need to work more on it. I wouldnt want to mention the problems until you give it a try.
|
Sunil Kumar
http://goodtoknowit.blogspot.com/
|
 |
Nattakan Lukkanapinit
Greenhorn
Joined: Apr 24, 2010
Posts: 16
|
|
Sunil Kumar wrote:You have quiet a few problems here
Line 32 : You are iterating on the string array(of length 13) using the length of corresponding element of the array(38). Clearly, when you reach at 13 on str_data[z], it will throw ArrayIndexOutOfBounds
You can fix the above by using str_data.length, but your code piece wouldnt return the desired results. You need to work more on it. I wouldnt want to mention the problems until you give it a try.
thanks for everyone who help me.
ok i fixed all the problem and the program can run without error
this is output of my test program just in main
|
 |
 |
|
|
subject: Convert 1d array to 2D boolean
|
|
|