Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions HelloApp.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
public class HelloApp {
public static void main(String[] args) {
if (args.length > 0) {
System.out.println("Hello, " + args[0] + "!");
} else {
if (args.length == 0) {
System.out.println("Hello, World!");
} else {
StringBuilder nameBuilder = new StringBuilder();

for (String name : args) {
nameBuilder.append(name).append(", ");
}

Comment on lines +7 to +11
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be trailing whitespace on the blank lines in this block (e.g., the empty lines after new StringBuilder(); and after the loop). Please remove trailing spaces to avoid unnecessary diffs and potential style/lint failures.

Suggested change
for (String name : args) {
nameBuilder.append(name).append(", ");
}
for (String name : args) {
nameBuilder.append(name).append(", ");
}

Copilot uses AI. Check for mistakes.
if (nameBuilder.length() > 0) {
String names = nameBuilder.substring(0, nameBuilder.length() - 2);
System.out.println("Hello, " + names + "!");
}
Comment on lines +6 to +15
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the else branch, if (nameBuilder.length() > 0) is redundant because this code path already implies args.length > 0. Also building with a trailing ", " then trimming via substring is harder to read and does extra work; consider String.join(", ", args) or StringJoiner to avoid the trim step.

Suggested change
StringBuilder nameBuilder = new StringBuilder();
for (String name : args) {
nameBuilder.append(name).append(", ");
}
if (nameBuilder.length() > 0) {
String names = nameBuilder.substring(0, nameBuilder.length() - 2);
System.out.println("Hello, " + names + "!");
}
String names = String.join(", ", args);
System.out.println("Hello, " + names + "!");

Copilot uses AI. Check for mistakes.
}
}
}
Loading