• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multi Dimension Array  RSS feed

 
Gaurav x Jain
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Above code genrate :
2D-Array:-1
2D-Array:-2
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at TestArray7.main(TestArray7.java:15)
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the value returned by score.length? How many elements do the nested arrays have?
And finally, what's the termination condition of the inner loop?
 
Gaurav x Jain
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
score.length value is=2
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check again. Because it is not 2.
 
Tarun wadhwa
Greenhorn
Posts: 14
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

int size = score.length;
System.out.println(size);

Just ADD these 2 line before the for loop you will get the answer of your question.

"The more you play with It the more you learn"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!