• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Convert 1d array to 2D boolean

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nattakan Lukkanapinit wrote:I have an error at line 38 and 32.


What is the error?
 
Nattakan Lukkanapinit
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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)
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Nattakan Lukkanapinit
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic