Lecture 16
6
test ? x : y
•Has value x if test is true, else has value y
•
•
•
•
•same as
if (a > b) {
   max = a;
}
else {
   max = b;
}
max = ( a > b ) ? a : b;
Repeat slide from last lecture. Not discussed then. If you use this elegant construction you’re speaking Java like a native rather than a newcomer. Whether or not you use it in the code you write, you need to be able to read it since other people use it in programs you read.