Site hosted by Angelfire.com: Build your free website today!

One Through 10

If you wish to view the code only, check this page. You can click the links and it should open up in a notepad file.

 

class OneThroughTen {
public static void main (String[] args){
for (int i=1; i<11; i++){
System.out.println(+ i);
}
}
}
 

 

 

NEW TERMS!

for: Ah yes, the for loop. In a for loop, you must have a variable set to a number, a comparison between the variable and another number, and what to do if the previous statements are true. In this case we have:

int=1: This part right here declares the value of the variable.

i<11: This part says that as long as i is less than 11...

i++: This part tells the computer what to do as long as i is less than 11. In this case, it will add 1 to i until it is less than 11.

System.out.println(+i): This will print out the variable i. To print a variable, you do not put quotes around it.