Results 1 to 4 of 4
Thread: for loop help
- 03-17-2011, 01:11 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 31
- Rep Power
- 0
for loop help
I have an exam tomorrow in class and I am stuck on creating 2 separate for loops
The first is reproducing even numbers from 2 to 10.
Here is what I have...
public class loops {
public static void main(String[] args)
{
for (int i=0; i<=10; i+=2);
System.out.println(i + "");
}
}
It says there is no variable for i which I don't understand...
The second loop I have to make is creating a loop that makes a sentence repeat four times which I am completely lost on
any help is greatly appreciated
- 03-17-2011, 01:17 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
You have a misplaced semicolon. Also a better approach is to use and if clause and the modulus operator. The second part is basic. Start it and post your best try.
- 03-17-2011, 01:33 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 31
- Rep Power
- 0
- 03-17-2011, 01:37 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Similar Threads
-
JTextField loop 2x for-loop WEIRD!
By Streetproject in forum AWT / SwingReplies: 2Last Post: 02-16-2011, 05:46 PM -
[Q] Loop issue (while loop)
By iriscience in forum New To JavaReplies: 9Last Post: 01-31-2011, 04:21 PM -
Convert do while loop to for loop
By sandeeptheviper in forum New To JavaReplies: 3Last Post: 01-03-2011, 12:37 PM -
How can I rewrite the following while loop using a for loop?
By gt11990 in forum New To JavaReplies: 5Last Post: 04-30-2010, 05:05 PM -
while-loop stopping on first loop
By davester in forum New To JavaReplies: 6Last Post: 06-26-2009, 08:46 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks