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

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -