Some Notes:

1- in.nextInt(); reads an integer from the user, blocks until the user enters an integer into the console and presses ENTER. The result integer has to be saved in order to use it later on, and to do so save it into a variable, something like this:

int value = in.nextInt();

In your code, you need to assign the 3 integers that the user enters to the corresponding variables:

System.out.println("Enter min value: ");
min = in.nextInt();
System.out.println("Enter max value: ");
max = in.nextInt();
System.out.println("Enter increment value: ");
increment = in.nextInt();

2- You are implementing the loop very well, but you just need to use the user's inputs rather than using explicit integers:

for(int i = min; i <= max; i += increment)
{
    System.out.println(i);
}
Answer from Eng.Fouad on Stack Overflow
🌐
Sololearn
sololearn.com › en › Discuss › 1492044 › what-to-do-to-increment-by-2-instead-of-1-
What to do to increment by 2 instead of 1 ? | Sololearn: Learn to code for FREE!
Here ++operator increments the value of test by 1 .You can also write like this test += 1; it means test = test+1; For incrementing the value of test by 2,3 or by any number you just need to write how much times you want to increment it .
Discussions

How do I use Increment operators (++) to increase a value more than 1?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
32
13
March 6, 2022
How to make for loops in Java increase by increments other than 1 - Stack Overflow
The longhand form of "++j" is "j ... as terse a shorthand as incrementing by one. "j + 3", as you know by now, doesn't actually change j; it's an expression whose evaluation has no effect. ... In this loop you are using shorthand provided by java language which means a postfix ... More on stackoverflow.com
🌐 stackoverflow.com
Post and Pre Incrementing?
Postincrement = (counting directly from 1 - 10) 1+1 = 2, 2+1=3, 3+1 =4, 4+1 = 5...... ... You can really see how post and pre incrementing/decrementing variables works when you use arrays in Java. Let's say you have an array named mylist that has a few decimal values. More on teamtreehouse.com
🌐 teamtreehouse.com
3
June 14, 2015
Is there a way to pre increment by more than 1 in Java? - Stack Overflow
In Java you can do a post increment of an integer i by more that one in this manner: j + i += 2. I would like to do the same thing with a pre increment. e.g j + (2 += i) //This will not work More on stackoverflow.com
🌐 stackoverflow.com
🌐
JavaBeat
javabeat.net › home › how to increment a java for loop by 2
How to Increment a Java for Loop by 2
July 23, 2023 - Specify a “for” loop that iterates along the values from “0” till “7” with a step of “2” using the “addition assignment operator (+=)”. It is such that upon each iteration, the iterated values will be incremented by “2”.
🌐
Java2Blog
java2blog.com › home › core java › java basics › increment for loop by 2 in java
Increment for Loop by 2 in Java - Java2Blog
September 24, 2022 - Let’s say we want print all even numbers between 1 to 20 in Java. We can write a for loop and start the loop from 2 by using i=2 in initialization part and increment the loop by 2 in each iteration by using i+=2.
🌐
Reddit
reddit.com › r/javahelp › how do i use increment operators (++) to increase a value more than 1?
r/javahelp on Reddit: How do I use Increment operators (++) to increase a value more than 1?
March 6, 2022 -

Just to preface, this isnt homework - Im self learning. Ive used Stack overflow but I dont think im searching the right thing, so I cant find what Im looking for

For my study book (Learn Java the Hard Way) , i'm on an exercise where I have to increase

i = 5;

to 10 by only using ++ , i know I could do

i++; on repeated lines but my study drill says I can do it on one. Which I would like to figure out

"Add code below the other Study Drill that resets i’s value to 5, then using only ++, change i’s value to 10 and display it again. You may change the value using several lines of code or with just one line if you can figure it out. "

Perhaps ive read it wrong but I cant find a way of using only ++ to do this in one line.

Ty for the help :)

🌐
Freejavaguide
freejavaguide.com › increment_decrement_operators.htm
Increment & decrement operators - Java tutorial | freejavaguide.com
class CountToTwenty { public static void main (String args[]) { int i; for (i=0; i <=20; i += 2) { //Note Increment Operator by 2 System.out.println(i); } } //main ends here } As you might guess there is a corresponding -= operator. If we wanted to count down from twenty to zero by twos we ...
🌐
Blogger
javahungry.blogspot.com › 2023 › 05 › increment-for-loop-by-2.html
Increment for Loop by 2 in Java with examples | Java Hungry
To increment for loop by 2 in Java, we only need to change the increment/decrement part of the for loop.
Find elsewhere
Top answer
1 of 13
137

That’s because j+3 doesn’t change the value of j. You need to replace that with j = j + 3 or j += 3 so that the value of j is increased by 3:

for (j = 0; j <= 90; j += 3) { }
2 of 13
48

Since nobody else has actually tackled Could someone please explain this to me? I believe I will:

j++ is shorthand, it's not an actual operation (ok it really IS, but bear with me for the explanation)

j++ is really equal to the operation j = j + 1; except it's not a macro or something that does inline replacement. There are a lot of discussions on here about the operations of i+++++i and what that means (because it could be intepreted as i++ + ++i OR (i++)++ + i

Which brings us to: i++ versus ++i. They are called the post-increment and pre-increment operators. Can you guess why they are so named? The important part is how they're used in assignments. For instance, you could do: j=i++; or j=++i; We shall now do an example experiment:

// declare them all with the same value, for clarity and debug flow purposes ;)
int i = 0;
int j = 0;
int k = 0;

// yes we could have already set the value to 5 before, but I chose not to.
i = 5;

j = i++;
k = ++i;

print(i, j, k); 
//pretend this command prints them out nicely 
//to the console screen or something, it's an example

What are the values of i, j, and k?

I'll give you the answers and let you work it out ;)

i = 7, j = 5, k = 7; That's the power of the pre and post increment operators, and the hazards of using them wrong. But here's the alternate way of writing that same order of operations:

// declare them all with the same value, for clarity and debug flow purposes ;)
int i = 0;
int j = 0;
int k = 0;

// yes we could have already set the value to 5 before, but I chose not to.
i = 5;

j = i;
i = i + 1; //post-increment

i = i + 1; //pre-increment
k = i;

print(i, j, k); 
//pretend this command prints them out nicely 
//to the console screen or something, it's an example

Ok, now that I've shown you how the ++ operator works, let's examine why it doesn't work for j+3 ... Remember how I called it a "shorthand" earlier? That's just it, see the second example, because that's effectively what the compiler does before using the command (it's more complicated than that, but that's not for first explanations). So you'll see that the "expanded shorthand" has i = AND i + 1 which is all that your request has.

This goes back to math. A function is defined where f(x) = mx + b or an equation y = mx + b so what do we call mx + b ... it's certainly not a function or equation. At most it is an expression. Which is all j+3 is, an expression. An expression without assignment does us no good, but it does take up CPU time (assuming the compiler doesn't optimize it out).


I hope that clarifies things for you and gives you some room to ask new questions. Cheers!

🌐
JavaBeat
javabeat.net › home › how to use increment ++ operator in java
How to Use Increment ++ Operator in Java
March 20, 2024 - Next, we employ the addition assignment operator “+=” to increment the “inputNum” value by 2.
🌐
Medium
medium.com › @er.nancybhardwaj › java-basics-increment-operators-5c479c60921c
Java Basics — Increment Operators | by Nancy Bhardwaj | Medium
June 8, 2023 - Java Basics — Increment Operators Increment operators is used to increase the value by 1 Types of Increment Operators Post Increment Pre Increment Post Increment Operator In simple words, it means …
🌐
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 first for loop, the variable i is initialized to 0, incremented by 1 after each iteration, and the loop executes until i is no longer less than 5. This will output the numbers from 0 to 4. 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. Java also allows you to simplify expressions using assignment operators.
🌐
Quora
quora.com › Is-it-possible-for-a-for-loop-in-Java-to-go-up-in-different-increments-I-want-to-write-a-loop-that-starts-with-1-but-then-goes-up-to-100-200-all-the-way-until-1000-How-would-you-write-a-code-to-do-that
Is it possible for a 'for loop' in Java to go up in different increments? I want to write a loop that starts with 1, but then goes up to 100, 200, all the way until 1000. How would you write a code to do that? - Quora
Set the counter to 1 before loop entry, then after you have used the counter value, increment it by either 99 (if counter value < 100) or 100 (if counter value is greater than or equal to 100) b) A more general solution: Preload an array with the counter values you are going to want, using a literal assignment. Use a for loop (going from 0 to 10 in your example, and use the for loop index to get the count ... Assuming you want to make use of the above sequence of values in some way, there are 2 basic possibilities:
🌐
Baeldung
baeldung.com › home › java › core java › a guide to increment and decrement unary operators in java
A Guide to Increment and Decrement Unary Operators in Java | Baeldung
February 17, 2025 - First, let’s look at a code snippet using the pre-increment unary operator: int operand = 1; ++operand; // operand = 2 int number = ++operand; // operand = 3, number = 3
🌐
Dummies
dummies.com › article › technology › programming-web-design › java › increment-and-decrement-operators-in-java-172144
Increment and Decrement Operators in Java | dummies
July 1, 2025 - Increment (++) and decrement (--) operators in Java programming let you easily add 1 to, or subtract 1 from, a variable.
🌐
Trinket
books.trinket.io › thinkjava2 › chapter6.html
Loops and Strings | Think Java | Trinket
Specifically, ++ is the increment operator; it has the same effect as i = i + 1. And -- is the decrement operator; it has the same effect as i = i - 1. 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:
Top answer
1 of 3
1
Hey randy, Post incrementing means that the variable will increment after it is processed. This will take a copy of the variable and then add it to the next number when the compiler gets to this line of code. So lets say we have a line of code that say's i++. This translates to i = i+1. You see here that i needs to be recreated and then incremented by one. Preincrement means the value will be incremented before it is processed. Generally both increments get the job done the same way. However, one requires a little less work and can save memory on heavy memory consuming programs. However, the performance gain is very little but just keep in mind that Postincrement duplicates the value in the variable then adds to it while pre increment just adds to what is already there. Think of it like this: Preincrement = (counting directly from 1 - 10) 1, 2, 3, 4, 5 ,6 ,7 8, 9, 10 Postincrement = (counting directly from 1 - 10) 1+1 = 2, 2+1=3, 3+1 =4, 4+1 = 5......
2 of 3
2
Hi Randy, You can really see how post and pre incrementing/decrementing variables works when you use arrays in Java. Let's say you have an array named mylist that has a few decimal values. Let's also say you have a variable named index that you are going to use to replace some values in this array. We are going to set the indices of the array to certain values depending on what the index is. Different behaviors occur when you use post and pre increment/decrement behaviors. If you prefix the index variable with an increment/decrement, the index variable will go up by 1 (or down by 1) and then the compiler will use that value in the index variable as the value for the index of the array. If you postfix the increment/decrement, the compiler will use the current value of index for the index of the array and then increase/decrease. ```java //create array double[] mylist = { 1.2, 2.4, 4.6 }; //create indexing variable int index = 0; //First let's prefix //this causes index to be 1 and then replaces the value at index 1 with 7.2 mylist[++index] = 7.2; //mylist is now { 1.2, 7.2, 4.6 } //when you run the command below //the current value of index is used which means that the index is 1 //and then index is increased and becomes 2 mylist[index++] = 9.8; //mylist is now { 1.2, 9.8, 4.6 } ``` Hopefully now you can see how the post and pre increment/decrement work.
🌐
Medium
medium.com › buzz-code › java-8-increment-decrement-operator-15e6e66590e0
Java 8 | Increment / Decrement Operator | by Student Kim | Buzz Code | Medium
January 11, 2021 - So when the unary operator is in front of the variable ++a /--a, we call it as pre-increment/decrement operator. And it changes the value of the variable first, and use the new variable on the line of the code.
🌐
How to do in Java
howtodoinjava.com › home › java flow control › for loop
Java For Loop (with Examples) - HowToDoInJava
November 20, 2023 - Value at index 0 is 0 Value at index 1 is 1 Value at index 2 is 2 Value at index 3 is 3 Value at index 4 is 4 ... First, 'int i = 0' is executed, which declares an integer variable i and initializes it to 0. Then, condition-expression (i < ...
🌐
Coderanch
coderanch.com › t › 778089 › java › Ternary-operator-increment-operator
Ternary operator with increment operator (Beginning Java forum at Coderanch)
Know its late and guess you have already got an answer. Still, I would like to offer my explanation. ++ after a variable is post increment and it means that first, the variable value is used in the same statement and then incremented. After this line sheep is incremented and it becomes 2.