• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

serialization

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
     
    reply
      Bookmark Topic Watch Topic
    • New Topic