Well it looks like you just want:

for(int i = 10; i >= 0; i--){
    System.out.println(i);
    System.out.println(10 - i);
} 

Is that the case? Personally I'd normally write this as an increasing loop, as I find it easier to think about that:

for (int i = 0; i <= 10; i++) {
    System.out.println(10 - i);
    System.out.println(i);
} 

Note that your string example is really inefficient, by the way - far more so than introducing an extra variable. Given that you know the lengths involved to start with, you can just start with two char[] of the right size, and populate the right index each time. Then create a string from each afterwards. Again, I'd do this with an increasing loop:

char[] forwardChars = new char[str.length()];
char[] reverseChars = new char[str.length()];
for (int i = 0; i < str.length(); i++) {
    forwardChars[i] = str.charAt(i);
    reverseChars[reverseChars.length - i - 1] = str.charAt(i);
}
String forwardString = new String(forwardChars);
String reverseString = new String(reverseChars);

(Of course forwardString will just be equal to str in this case anyway...)

Answer from Jon Skeet on Stack Overflow
Discussions

java - Best idiom for a decrementing loop - Stack Overflow
And as an aside, I favor the prefix ... for for-loops, since it will avoid taking an unnecessary copy of idx (though many compilers will probably recognize this and fix it for you). ... for (int idx = len; --idx >= 0; ) is more concise. FWIW, the pre-decrement form --idx >= 0 requires fewer Java byte codes ... More on stackoverflow.com
🌐 stackoverflow.com
java - Decrement on While loops - Stack Overflow
e = 1(iteration 1), 2^1, e (1) ... e (1) decremented to 0, e = 3 (iteration 3), 2^3… ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... Stack Overflow chat opening up to all users in January; Stack Exchange chat... 4420 Iterating over a dictionary using a 'for' loop, getting keys · 3263 JavaScript closure inside ... More on stackoverflow.com
🌐 stackoverflow.com
for loop - How to count from 10 to 1 in java - Stack Overflow
For a simple Java program where I want to make the program count from 10 to 1 by incrementing of 2 or 3 or 4 how would I change this code? public class ExampleFor { public static void main(S... More on stackoverflow.com
🌐 stackoverflow.com
November 4, 2014
java - Why does decrement loop runs faster than increment loop? - Stack Overflow
I tested both the loops in online ... then decrement loop. Program execution depends upon many factors. When sometimes we run the same program on same machine many times we gets different execution times. So it depends upon many factors. ... Sir Evgeniy Dorofeev has given an excellent explanation which an expert only can give. Finally, you need to consider the performance of your CPU. When considering a benchmark to determine the overall performance of a Java application, ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Quora
quora.com › How-can-we-use-the-loop-in-Java-to-decrement-the-string
How can we use the loop in Java to decrement the string? - Quora
Example — decrement a lowercase alphabetic counter ("a".. "z"), with wrap/borrow: ... Use for/while loop to repeatedly modify and print or collect states.
🌐
Tutorial Gateway
tutorialgateway.org › java-for-loop
Java For loop
March 25, 2025 - If the condition is False, then it will exit. After completing the iteration, it will execute the Increment and Decrement Operator inside the for loop to increment or decrement the value.
🌐
Codefinity
codefinity.com › courses › v2 › 8204075c-f832-4cb9-88b1-4e24e74ebdcb › 3e046a04-a59c-4fc2-95d5-5d34cff8249b › d5d1873b-9640-4d8b-94de-d61ed41c8651
Learn Increment and Decrement | Loops
In the second for loop, the variable j is initialized to 5, decremented by 1 after each iteration, and the loop executes until j is no longer greater than 0. This will output the numbers from 5 to 1 in descending order.
🌐
Coderanch
coderanch.com › t › 753379 › java › Decrement-numbers-loop
Decrement of numbers using while loop (Beginning Java forum at Coderanch)
August 2, 2022 - This means that when they reach their minimal possible value and you decrement them, the value wraps around to the maximum possible value. So after the value -2,147,483,648 (the minimum for int) n wraps around to 2,147,483,647 (the maximum for int), the loop condition sees that this value is ...
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › what-are-the-restrictions-on-increment-and-decrement-operators-in-java
What are the restrictions on increment and decrement operators in java?
July 30, 2019 - The increment operator increments the value of the operand by 1 and the decrement operator decrements the value of the operand by 1. We use these operators to increment or, decrement the values of the loop after executing the statements on a value. ... public class ForLoopExample { public static ...
🌐
Netjstech
netjstech.com › 2019 › 06 › java-for-loop-with-examples.html
Java for Loop With Examples | Tech Tutorials
May 3, 2022 - Initialization– Initialization step is used to set the initial value of the variable which controls the for loop. Initialization is the first step in for loop execution and it is executed only once. The initilized variable is later incremented or decremented in the increment\decrement step of the loop.
🌐
javaspring
javaspring.net › blog › incrementing-and-decrementing-in-java
Incrementing and Decrementing in Java: A Comprehensive Guide — javaspring.net
In the first for loop, the i++ post-increment operator is used to increment the value of i after each iteration. In the second for loop, the j-- post-decrement operator is used to decrement the value of j after each iteration.
🌐
Reddit
reddit.com › r/learnjava › can someone explain increment and decrement operator in a while loop?
r/learnjava on Reddit: Can someone explain increment and decrement operator in a while loop?
January 15, 2020 -

I've been doing the MOOC Introduction to OOP course part 1 for a while, and I've been having a blast. I'm used to python, and no other language has got my attention like this, for some reason.

There is a thing, I don't quite understand. The increment operator in it self, raises the value of your variable by 1. However, in several excercises now, we have been doing something similar to this:

import java.util.Scanner;

public class ManyPrints {
    // NOTE: do not change the method definition, e.g. add parameters to method
    public static void printText() {
        System.out.println("In the beginning there were the swamp, the hoe and Java");
        // Write your code here
    }

    public static void main(String[] args) {
        // ask the user how many times the text should be printed
        // use the while structure to call the printText method several times
        Scanner reader = new Scanner(System.in);
        int num = 0;
        System.out.println("How many? ");
        int times = Integer.parseInt(reader.nextLine());
        
        
        while(num <= times) {
            printText();
            num++;
        }
    }
}

On the first try, I didn't even have the increment operator in my code, and it would just constantly print my code. Then I thought of this, because we have been doing it a lot, and it worked. However, I don't understand why. Why does the increment operator, make the program able to stop after the number in the user input? Why doesn't it just keep increasing the value by 1?
Sure while num is less or equal to times that part of the code runs, but if i remove the increment operator, it would be infinite.

Thank you.

🌐
BeginnersBook
beginnersbook.com › 2015 › 03 › for-loop-in-java-with-example
For loop in Java with example
This is a simple example of for loop. Here we are displaying the value of variable i inside the loop body. We are using decrement operator in the loop so the value of i decreases by one after each iteration of the loop and at some point the condition i>1 returns false, this is when the loop stops.
🌐
Funnel Garden
funnelgarden.com › java-for-loop
Java For Loop, For-Each Loop, While, Do-While Loop (ULTIMATE GUIDE)
Java for loops are structured to follow this order of execution: 1) loop initialization 2) boolean condition – if true, continue to next step; if false, exit loop 3) loop body 4) step value 5) repeat from step 2 (boolean condition) Here is a simple for loop incrementing values from 0 to 99. ... Here is a similar for loop decrementing values from 100 to 1.
🌐
Stack Overflow
stackoverflow.com › questions › 66329721 › decrement-by-a-certain-amount-on-java
loops - Decrement by a certain amount on java - Stack Overflow
the end number is where the loop would stop and the update number is how much the starting number should decrement by. so far this is the code I have and I'm stuck on how to keep the loop going until the end number. package jaba; import ...
🌐
Trinket
books.trinket.io › thinkjava2 › chapter6.html
Loops and Strings | Think Java | Trinket
If you want to increment or decrement a variable by an amount other than 1, you can use += and -=. For example, i += 2 increments i by 2: ... The loops we have written so far have three parts in common. They start by initializing a variable, they have a condition that depends on that variable, ...
🌐
Runestone Academy
runestone.academy › ns › books › published › csjava › Unit4-Iteration › topic-4-2-for-loops.html
4.2. For Loops — CS Java
Even though Java doesn’t require indention it is a good habit to get into. You will be told if any of the blocks are in the wrong order or not indented correctly when you click the “Check Me” button. public static void printEvens() { --- for (int i = 0; i <= 10; i+=2) { --- System.out.println(i); --- } // end for --- } // end method · You can also count backwards in a loop starting from the last number and decrementing down to 0 or 1.