Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Joe Buzo

Greenhorn
+ Follow
since May 23, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joe Buzo

Hi Raj:

the ternary operator is used as a short hand for a simple if-else statement, for example:

String result = "";
if ( getValue() == true ) {
result = "Value is true";
} else {
result = "Value is false";
}

could be written in a more compact format as:

String result = getValue() ? "Value is true" : "Value is false";

The key point to remember is that the ternary operator WILL return a value as a result of evaluating the condition. This value is normally assigned to a variable. In your case, you want to selectively execute logic based on the condition, so you need an if-else statement of the form:

if ( getValue() ) {
setValue("true");
} else {
setValue("false");
}

since "setValue" returns nothing (ie void).

Cheers,

Joe
13 years ago
Hi there:

I would like to purchase a preparation kit with plenty of mock exams for the SCJP 5.0 certification. While browsing the web, I came across a company called uCertify (http://www.ucertify.com/exams/SUN/CX310-055.html).

Does anyone have any comments (positive or negative) with this product?

Thanks...