• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Array  RSS feed

 
Alex Moradi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone

I started learning JAVA with How to program JAVA( Detail & Detail ) E-book;

In one example the book told this Code:





and i want use input and get data from user, and and modified that like below:



when i compile this code i got an error, where is my mistake ?

tnx for your answer.
 
Stephan van Hulst
Saloon Keeper
Posts: 7207
118
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your responses array has length 5, and you're trying to put result at index 5, which is the 6th element of the array. Recall that array indexing is zero-based.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!