+ 4
Order of strings inside a print method.
hey, Does anyone know whats happening with this as it dosent seem to work the way i thought it would đ€ System.out.println(("fun "+("is "+("java ")))); thanks
4 Answers
+ 10
Most operators including string concatenation always process from left to right.
The parentheses do prioritize the operations but it's the appending to front or back make the difference. đ
"A" + "B" not equals "B" + "A"
"A" + ("B" + "C") equals ("A" + "B") + "C"
+ 6
i expected to say "java is fun" i thought it might of printed in order of parenthisis 1st,2nd,3rd or is that not possible?
+ 5
Thanks guys, yep it dosent work âș so i made a simple way to solve it if anyone asks the same question.
String [] arr = {" fun!","is","Java "};
int i = arr.length-1;
for(;i>-1;i--){
System.out.print(arr[i]);
+ 2
I'm not sure what you expected, but you got what I expected. First, "java " is gotten. "is "+"java " is processed next yielding "is java ". "fun "+"is java " is processed last yielding "fun is java "