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)
About Ternary operator
Richard Wilson
Ranch Hand
Posts: 57
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,can anyone tell whether the Ternary operator
(?: ) does a full evaluation or a partial evaluation to the operands.
[ February 10, 2002: Message edited by: Richard Wilson ]
Richard Wilson
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
I like...
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The following link may be of help:
JLS 15.25 Conditional Operator ? :
Amazing how a simple piece of code can be of tremendous help
public class Test{ public static void main(String args[]){ int i1=1; int j1=2; int i2=3; int j2=4; int i5 = (true) ? (i1=10) : (j1=20); int i6 = (false) ? (i2=30) : (j2=40); System.out.println(i1+","+j1+","+i2+","+j2); } }
Output: 10,2,3,40
which means only the relevant operand is evaluated
HIH
[ February 10, 2002: Message edited by: Valentin Crettaz ]
My Linked In
Something about .... going for a swim. With this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Clarification about Ternary operator
Syntax error for ternary operator
can any one explain this
:?
String concatenation
More...