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
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
Programmer Certification (OCPJP)
How does it work...plz explain
Anish Nagraj
Greenhorn
Posts: 20
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Plz help me in finding out how this works...
x +=x < 0 ? 2 : -2;
when i print x i get as -3
how is it?
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
what is x initialized to ?
[My Blog]
All roads lead to JavaRanch
Anish Nagraj
Greenhorn
Posts: 20
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am really soryy for not specifying the initialization value...
x is initialised to -5;
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You have to figure out the precedence order of the operators,
and evalution order.
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#4779
x = -5
x += x < 0 ? 2 : -2
x += ((x < 0) ? 2 : -2) ( x < 0, so return 2 )
x += 2
x = -5 + 2
[ March 03, 2006: Message edited by: Satou kurinosuke ]
[My Blog]
All roads lead to JavaRanch
bnkiran kumar
Ranch Hand
Posts: 176
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The main reason this is happening is due to that
java
sees that all its operands are evaluated before performing an operation.
Kiran Kumar.
Anish Nagraj
Greenhorn
Posts: 20
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks a lot...
See where your hand is? Not there. It's next to this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Plz explain me the code
placing components in applet
Garbage Collection problem??
string function problem
Doubt on static
More...