jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0" Watch "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0" New topic

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

muhammad hanif

Joined: Mar 28, 2013
Posts: 1
why my program goes like this:

here the code

can you give a solution and explanation about that?
Mack Wilmot
Ranch Hand

Joined: Jul 27, 2011
Posts: 88

No, because I can't read it formatted as a Quote instead of Code.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63848

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?

[Asking smart questions] [About Bear] [Books by Bear]
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

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.

~ Mansukh
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link: http://aspose.com/file-tools
subject: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
jQuery in Action, 3rd edition