Results 1 to 3 of 3
- 04-06-2012, 02:39 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 5
- Rep Power
- 0
Make a loop that prints the lastnumber only
Hi
I just started with java course and are not very knowledgeable
I am stuck on a task that I think is very easy for all java expert here.
The task wants me to make the loop only print the last number, and not all numbers.
it is surely very easy but I am stuck and have to submit the task as quickly as possible.
someone who can help me with that?
THis is the loop:
for(int i = 0; i <= 5; i++){
int lastNumber = 0;
lastNumber = i;
System.out.println(lastNumber);
}Last edited by ramin; 04-06-2012 at 03:12 AM.
- 04-06-2012, 02:45 AM #2
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Re: Make a loop that prints the lastnumber only
Could you provide sample output? That code there should print out the variable i until it stops at 5.
- 04-06-2012, 03:11 AM #3
Member
- Join Date
- Jan 2012
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Txt to ArrayList only prints []
By Quasi Urbane in forum New To JavaReplies: 4Last Post: 04-27-2011, 07:16 PM -
Canvas Prints
By canvas02 in forum Reviews / AdvertisingReplies: 0Last Post: 02-18-2011, 05:33 PM -
List prints only the first row repeatedly in a loop
By yss1287b in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 11-16-2010, 02:21 PM -
Count each cell as it prints.
By Shyamz1 in forum New To JavaReplies: 9Last Post: 10-29-2010, 12:58 AM -
How can I make a loop, that writes a....
By Torgero in forum New To JavaReplies: 3Last Post: 03-10-2009, 04:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks