Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes how come this doesn't work java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how come this doesn Watch "how come this doesn New topic
Author

how come this doesn't work java?

saurabh pant
Greenhorn

Joined: Apr 16, 2012
Posts: 5
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

What specifically are you having trouble with? Are you getting incorrect output? Do you get compile or runtime errors? You need to give more information about your problem.

Hunter


"If the facts don't fit the theory, get new facts" --Albert Einstein
saurabh pant
Greenhorn

Joined: Apr 16, 2012
Posts: 5
When I give input:3
I get,

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at pack1.cube.main(cube.java:94)
Java Result: 1


I dry run it.i dont know where the problem resides..!!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

saurabh pant wrote:When I give input:3
I get,

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at pack1.cube.main(cube.java:94)
Java Result: 1


I dry run it.i dont know where the problem resides..!!


The error message is telling you exactly what's wrong. It's telling you that on line 94 of cube.java, you're trying to access the 4th element (at index 3) of an array that has fewer than 4 elements.
saurabh pant
Greenhorn

Joined: Apr 16, 2012
Posts: 5
I pinpointed d flaw...thanks a lot..!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

You're quite welcome!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37913
    
  22
Welcome to the Ranch Please avoid abbreviations like “d”.
saurabh pant
Greenhorn

Joined: Apr 16, 2012
Posts: 5
I will keep that in mind...Thanks for the site...a great support...indeed..!
 
wood burning stoves
 
subject: how come this doesn't work java?
 
Similar Threads
Can someone tell me why?
Dsplaying the alphabet with a loop?
HELP~~
Loops
June Newsletter Puzzle