Skip to content
Snippets Groups Projects
Commit 9313512e authored by adil.obol's avatar adil.obol
Browse files

Update file CmdEcho.java

parent b935728f
Branches main
No related tags found
No related merge requests found
......@@ -3,19 +3,15 @@ package no.uib.inf101.terminal;
public class CmdEcho implements Command {
@Override
public String run(String[] args) {
String result = "";
for (int i = 0; i < args.length; i++) {
result += args[i];
// Add a space after each argument except the last one
if (i < args.length - 1) {
result += " ";
}
StringBuilder sb = new StringBuilder();
for (String arg : args) {
sb.append(arg).append(" ");
}
return result;
return sb.toString();
}
@Override
public String getName() {
return "echo";
}
}
};
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment