#help with Indentation

1 messages · Page 1 of 1 (latest)

hard dove
#

I'm learning how to code in java but i dont fully understand the whole indentation thing.
The exercise im doing says
"Line 16: '}' should be on the same line.
Line 20: '}' should be on the same line."

if anyone could explain what im not understanding that would be appreciated

lusty vineBOT
#

<@&987246399047479336> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

ould be on the same line.

Indentation is important in programming because it helps make your code more readable and organized. In Java, indentation is typically done using spaces or tabs to create a visual hierarchy of your code.

In this case, the error message is telling you that the closing curly braces '}' should be on the same line as the code block they are closing. For example:

if (condition) {
    // code block
}

In this example, the closing curly brace '}' is on the same line as the code block it is closing (the if statement).

Make sure to check your code for proper indentation and ensure that all opening and closing curly braces are on the same line as their respective code blocks. This will help improve the readability of your code and make it easier to debug any errors.

north raft
#

indentation is used to make your code more presentable and easier to understand

gritty sequoia
#

my guess is that it wants

#
if (...) {

}
else {

}
#

or

#
if (...) {

} else {

}
#

and not

#
if (...) {

}

else {

}
#

this is just whatever autochecker you are going against

hard dove
north raft
#

probably

hard dove
#

ah okay, thank you so much i was sitting here confused wondering what i did wrong😅

north raft
silent galleon
#

Java isn't yaml, the indentation doesn't matter. In this case it's just a checkstyle rule to learn you a certain convention.

hard dove
gritty sequoia
midnight trout
north raft