Reputation: 23
Today was my first class at the institute for java developer course. The lecturer put forward a question for the whole class:
Find the biggest number among two numbers by using only one condition, i.e., if condition only. Do not use any other conditions like using if-else, else-if, using if two times, ternary, loops, etc.
Upvotes: 2
Views: 646
Reputation: 436
int first = 10;
int second = 20;
int max = first;
if (second > max) {
max = second;
}
System.out.println(max);
Upvotes: 0