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
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Programmer Certification (OCPJP)
Simple Math Expression
Joshua Fix
Ranch Hand
Posts: 57
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is killing me... I don't know if I'm tired or what. How is the output of this 7???
int i = 1; int result = 5 + i++ % 4 * i; System.out.println(result);
SCJP 5.0
Chandran Madesh
Greenhorn
Posts: 18
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi, The output 7 is correct.
int i = 1; int result = 5 + i++ % 4 * i; // 1) i++ %4 = 1 (now i get increment so now i =2) 2) 1 * 2 = 2 3) 5 + 2 = 7 System.out.println(result);
the operator priority is % , * ,+ in the above code.
<b>Chandran.M<br /> <br /> <br /> Do Your Best <br /></b>
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Passing the method's return as argument
Putting Binary Search Tree into an array
Help with int Conversion to String
Post Operator
GCD calculation using Euclidean algorithm fails
More...