Using a more modern solution, you could use something along the lines of this:
import java.util.stream.IntStream;
public class Test {
public static void main(String[] args) {
int n = Integer.parseInt("10");
int sum = IntStream.range(0, n).reduce(n, (a, b) -> a + b);
System.out.println("Total is " + sum);
}
}
Obviously in my example it doesn't take any input from the CLI, it's just a fixed value, but I'm certain you get the idea. You may be asking why I like solution over the likes of a more traditional for loop purely because of how small & concise it is, I just generally find it much easier to read & maintain.
Not to mention that a solution like this introduces you to some concepts related to functional programming, such as immutability. While cools guys like Eric Elliott may do a lot of tutorials in JavaScript, the principles are transferable to practically any language! :)
A little bit of theory
While functional programming rocks, the precise example I've provided may not be the most appropriate if your core target is performance. In this case, it is better to use a more traditional solution, but given it's such a primitive application/piece of code, I think it's fine.
From a computational complexity perspective, from a speed & branching perspective, it's roughly the same as a traditional solution, however, just by using a stream, never mind creating the range, it's likely using more memory than a simple for loop. But you could also argue that the compiler would do such a great job that it may actually implement this as a traditional for loop.
With my solution, it does 9 iterations, if you were to use a for loop like the one @azro provided, then the code would result in 10 iterations, so that's also something to think about I guess! :)
Edit
I should note that this solution will work with Java 8+.