for loop - How to count from 10 to 1 in java -


For a simple Java program where I want to increase the program from 2 to 3 or 4 to 10 to 1 Can I change this code? Public class examples {public static zero main (string [] args) {// (for int i = 10; i>; i -) {System.out.println ( "I =" + I); }}}}

Change the loop for : < For / p>
  (int i = 10; i> 0; i- = 2) {System.out.println ("i =" + i); }  

i- = 2 is an abbreviation i = i-2
This means that the new value < Code> i
i will have an old value of zero.
i - this i = i-1 , which is i- = 1

Can also be written as

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -