Can any one please explain me what the following statements means. i came across it while studying serialization.
System.out.print( + + a.b + " ");
thanks in advance.
posted 4 years ago
It means whoever wrote it is trying to confuse you. There is some very bad coding in that line. I think you have copied it wrongly, too, adding a space; it will only compile if you write ++, but + + will give you an error.
You need to look up the precedence of the operators: . > ++ and ++ > + and + > everything else because it is in brackets.
1: Highest precedence . You are getting the "b" member of the object "a" (or the class "a" if it is static).
2: Next down ++. You are applying the pre-increment operator to it, increasing its value by 1, so it will return 1 more than its previous value.
3: + You are catenating the String object following, a single space.
4: () The whole thing is now the argument to the print method.
I am sure you can work the rest out for yourself. I am also sure you would never write that sort of code yourself, and hope if you ever did you would be sacked (if an employee) or failed (if a student) on the spot