Click here to Skip to main content
15,887,880 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this.maxMarks = this.marks1 > this.marks2 ? (this.marks1>this.marks3 ? marks1 : marks3) : (this.marks2 > this.marks3 ? this.marks2 : this.marks3);
Posted

Let's start from the simpler example:
Java
int first = //...
int second = //...
int result = first > second ? first * 2 : second * second;

The last line is strictly equivalent to
Java
int result;
if (first > second)
   result = first * 2;
else
   result = second * second;

Using this idea, you can understand your example, where the same feature is used in a nested way: two expressions in round brackets are the branches or first '?' operator and use '?' themselves.

—SA
 
Share this answer
 
You can find all the answers you need by working through https://docs.oracle.com/javase/tutorial/java/index.html[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900