Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Programmer Certification (OCPJP)
Increment operator
Vivek Raj
Ranch Hand
Posts: 33
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
int a = 1; a += ++a;// a is now 3
the value of a after this operation is 3.
Why its not 4, as ++a should change the value of a to 2 and then a+a (2+2) should be 4.
OCPJP 1.6
Rishi Dhar
Ranch Hand
Posts: 35
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
View it as
a= a + ++a;
now after substitution it become
a=1 + 2;
OCPJP 90% OCWCD EE6 92%
Vivek Raj
Ranch Hand
Posts: 33
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
ok I got it..
values are substituted from left to right in an expression
so,
if int a=0;
a = a + ++a; // would be evaluated as 0 + 1;
a = ++a + a; // would be evaluated as 1 + 1;
OCPJP 1.6
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Making a binary to decimal converter
surprise....boolean check
Doubt regarding question from danchisholm on operators
how to create a java program that can print the value of any expresion ?
Operator Precedence in Java
More...