The Artima Developer Community
Sponsored Link

Java Answers Forum
For- Loops and Printing

3 replies on 1 page. Most recent reply: Nov 12, 2002 11:46 AM by Jade Era

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Jade Era

Posts: 4
Nickname: jade
Registered: Nov, 2002

For- Loops and Printing Posted: Nov 7, 2002 7:42 AM
Reply to this message Reply
Advertisement
I am working on arrays and everything works just fine except for my println statement. This println statement worked before I included the (names) line. I need to print all elements in both arrays together (as a list). Is it illegal to use two println statements for one for-loop?
Any input is appreciated!

}
for (int i = 9; i >= 0; i--)
System.out.println(names);
System.out.println(scores);
System.exit(0);

I used this loop: for (int i = 0; i<10; i++) {
earlier in my program and Java/Textpad gives me this error:
i is already defined in main(java.lang.String[])
for (int i = 9; i >= 0; i--)
^


Jade Era

Posts: 4
Nickname: jade
Registered: Nov, 2002

Re: For- Loops and Printing Posted: Nov 7, 2002 8:55 AM
Reply to this message Reply
I forgot to include the index:

I am working on arrays and everything works just fine except for my println statement. This println statement worked before I included the (names) line. I need to print all elements in both arrays together (as a list). Is it illegal to use two println statements for one for-loop?
Any input is appreciated!

}
for (int i = 9; i >= 0; i--)
System.out.println(names);
System.out.println(scores);
System.exit(0);

I used this loop: for (int i = 0; i<10; i++) {
earlier in my program and Java/Textpad gives me this error:
i is already defined in main(java.lang.String[])
for (int i = 9; i >= 0; i--)
^

Dante T. Salvador

Posts: 19
Nickname: anteng
Registered: Nov, 2002

Re: For- Loops and Printing Posted: Nov 12, 2002 9:39 AM
Reply to this message Reply

for (int i = 9; i >= 0; i--)
System.out.println(names);
System.out.println(scores);
System.exit(0);

I used this loop: for (int i = 0; i<10; i++) {
earlier in my program and Java/Textpad gives me this error:
i is already defined in main(java.lang.String[])

for (int i = 9; i >= 0; i--)
^


you already declared int i in your first loop

try to delete int in the next loop, just initialize it.

Jade Era

Posts: 4
Nickname: jade
Registered: Nov, 2002

Re: For- Loops and Printing Posted: Nov 12, 2002 11:46 AM
Reply to this message Reply
Thanks! I figured it out. There was also something wrong with my inner for-loops.

Flat View: This topic has 3 replies on 1 page
Topic: need help Previous Topic   Next Topic Topic: How to delete random item from multi dimensional array

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use