nus-cs2113-AY2122S1 / forum

3 stars 1 forks source link

Regarding the A-CodingStandard, multi line output #47

Open DuckWillow opened 3 years ago

DuckWillow commented 3 years ago

Which one is the better coding standard when I try to output multiple lines?

logo = "____\n"

or

logo = """


                        blah
                        ____________________________________________________________
                        """;

The second one is suggested by IntelliJ. Why should we use """ """ instead of " "?

richwill28 commented 3 years ago

There is no such thing as a better coding standard, what is more important is that we have to follow a widely-accepted guideline and be consistent. In this module, we will have to follow this coding standard.

The second one is suggested by IntelliJ. Why should we use """ """ instead of " "?

Not sure what you meant by this. But you can adjust your code formatting on IntelliJ by going to.. File > Settings > Editor > Code Style > Java

richwill28 commented 3 years ago

Also, please use markdown when inserting code, otherwise it is difficult to read. You can do it like this, by using triple backticks.

```
Write your code here.
```

For more information, refer to this guide.

DuckWillow commented 3 years ago

image image

But I tried both """ and ''', neither of them works.

okkhoy commented 3 years ago

I suppose using text block with """ // string here """ is not allowed in Java 11 (at least that is what my IDE set to use Java 11 says).

Use this instead:

String logo = "\n"
        + "blah\n"
        + "\n";

If you are allowed to write text block (with """ // string here """) in the IDE, it may be the case that you haven't set up the project to use Java 11 properly.