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
17 changes: 14 additions & 3 deletions HelloApp.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
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();
boolean first = true;

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 this blank line; please remove it to keep diffs clean and avoid lint/formatting noise.

Copilot uses AI. Check for mistakes.
for (String name : args) {
if (!first) {
nameBuilder.append(", ");
}
nameBuilder.append(name);
first = false;
}

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 this blank line; please remove it to keep diffs clean and avoid lint/formatting noise.

Copilot uses AI. Check for mistakes.
System.out.println("Hello, " + nameBuilder.toString() + "!");
Comment on lines +6 to +17
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.

The manual StringBuilder + first flag loop is more verbose than necessary for joining arguments. Consider using String.join(", ", args) (if targeting Java 8+) to simplify and reduce branching.

Suggested change
StringBuilder nameBuilder = new StringBuilder();
boolean first = true;
for (String name : args) {
if (!first) {
nameBuilder.append(", ");
}
nameBuilder.append(name);
first = false;
}
System.out.println("Hello, " + nameBuilder.toString() + "!");
String joinedNames = String.join(", ", args);
System.out.println("Hello, " + joinedNames + "!");

Copilot uses AI. Check for mistakes.
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.

nameBuilder.toString() is redundant here because string concatenation will call toString() implicitly. Using nameBuilder directly avoids the extra call and is a bit clearer.

Suggested change
System.out.println("Hello, " + nameBuilder.toString() + "!");
System.out.println("Hello, " + nameBuilder + "!");

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