• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

 
muhammad hanif
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why my program goes like this:



here the code





can you give a solution and explanation about that?
 
Mack Wilmot
Ranch Hand
Posts: 88
Linux Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, because I can't read it formatted as a Quote instead of Code.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make your code readable, please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.

I've gone ahead and added the code tags for you. See how much easier the code is to read?
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Salaam Ay-Lekum Muhammad. Welcome to the ranch. Before answering your query, I have a question of my own. What are you trying to do with this code? I do not understand the language in which you have written the instance variables/object names/text in SOPs. Also, it appears that you are new to Java language. Is it? Because this is a very basic doubt.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15448
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In lines 21, 22 and 23 you are creating three arrays-of-arrays, with size zero by zero, because at that point baris and kolom are zero.

You change the values of baris and kolom in lines 29 and 32 in the inputBarisKolom() method, but that ofcourse does not automatically change the size of matriksA, matriksB and matriksC. You'll have to re-initialize those with the correct size.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic