You can simply String.join
the strings together and print them. Like:
public class Foo {
public static void main(String [] args) {
System.out.println(String.join(" ",args));
}
}
The first argument, the delimiter
, is here " "
(a string containing one space). Such that there is a space between two arguments.
Note that this program is almost identical to the echo
program you see on a lot of operating systems.
Finally note that although this program does not contain a loop, the String.join
definitely need some form of looping inside the method.
No comments:
Post a Comment