throwaway123pie
throwaway123pie

Reputation: 23

Go through for loop specific number of times like range() in python

I finally got around to learning java after continuously bashing it as a python elitist lol. All jokes aside, I'm looking forward to playing with java and already having some fun with it.

I couldn't seem to find a simple solution for my problem. Basically, I want to make a for loop that will repeat itself a specific amount of times similar to this as in python:

for i in range(10):
    Print("You win")

but for java of course.

I tried the following after some digging on the internet:

for (int i : new Range(10)) {
    System.out.println("You win");
}

The following code gave me an error saying:

Range cannot be resolved to a type

Any help would be appreciated.

Upvotes: 0

Views: 49

Answers (1)

tsamridh86
tsamridh86

Reputation: 1496

A simple for loop would do the trick:

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

Upvotes: 1

Related Questions