File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Operators

 
vikas singh
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please suggest the following if I compile undermentioned 3 sets separetly :
int a=5;
Set1:
// Here at first println statement, the val. of a is 5, agreed�
// And the second println prints 6, agreed �
System.out.println("val of a :"+(a++)); // o/p=5
System.out.println("val of a :"+(a)); // o/p=6
Set2:
// Here val. of a is incremented first and assigned to
// variable a.I agree �
// And the second println prints 6, agreed �
System.out.println("val of a :"+(a=++a)); // o/p=6
System.out.println("val of a :"+(a)); // o/p=6
Set3:
// Here at first println statement, the val. of a is 5
// the same is assigned
// to variable a, but why incrementation doesn't take
// place after that.
// i.e second println should print 6 as a's value but
// o/p is 5 , Pl suggest.
System.out.println("val of a :"+(a=a++)); // o/p=5
System.out.println("val of a :"+(a)); // o/p=5
Thanks,
Vikas s.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've a detailed explanation and proof code about this kind of stuff here:
Java Left-to-right rule of evaluation
Thanks!
Roseanne
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic