I have to create a for loop which allows a sentence to be displayed 5 times with java


Current behavior:

Desired behavior

Repl link:

code snippet

Welcome to Replit Ask!

It seems like this is to do with a homework task. Note we do not give homework help here, but we can give you pointers in the right direction.

Here’s a quick template for Java for loops:

for (int i = 0; i < x; i++) {
    // Run this code x times

I’ll leave the rest to you :slightly_smiling_face:

1 Like

thank you, i did this .

for(int i=0; i<5;i++);
        System.out.println("i have a dog");

it seems like the system.out.printl doesnt work

Is your code in your class Main (or similar) block?

You have to wrap the commands in the for loop in {}, and you cannot have a semicolon on the end of the for loop.
Here’s some examples:

for (condition) {
// OR
for (condition)