Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Nisha Gor   on Aug 01 In Java Category.

  
Question Answered By: Kay Rodriguez   on Aug 01

Your first for loop goes from 0 to 5 that is 6 different elements and I
don't think you want 6 elements (both ma[] and sk[] are 5 elements
long). The challenge for you in this question is that you have two
different arrays feeding information.

I would look at using Stack ma = new Stack(); Instead of Stack ma[] =
new Stack[5]; I think that what you are doing currently is creating a
array of Stack Objects.

Now looping though a length of a collection is realy easy, in fact you
have probably seen a example of this in one of your tutes. If you type
arrayName.length or collectionName.getSize() it reports the size of the
array/collection.

for (int i = 0; i <= arrayName.length ; i++) will loop though the exact
size of the array.

Your second for loop is probably going to be broken too.

Share: