Hi there,
I have encountered a piece of code in a sample exam question and I am unsure as to what it means.
This is the code:
class Test{
public static void main(String[] args){
for(int i = 0; i < args.length; i++){
System.out.print(i == 0 ? args : " " + args);
}
}
}
The question asked is "What will be the output when it's run using the following command: java Test good bye friend!"
The output is good bye friend! But the part I cannot understand is the part within the brackets in the System.out.print statement. Can anyone help me?
TL:DR
What's going on in line 4 of my code?
Thanks!