It is depends on the boolean expression is true or false. the main motive of this expression is which value should be assign .
expression : variable x=(expression) ? true value : false value
Source Code:
- public class ConditionalDemo {
- private static Scanner input;
- public static void main(String[] args) {
- input = new Scanner(System.in);
- int num1,num2,large;
- System.out.print("Enter two number: ");
- num1 = input.nextInt();
- num2 = input.nextInt();
- large = (num1>num2)?num1:num2;
- System.out.println("large no is ="+large);
- }
- }
Output:
Enter two number: 25 24large no is =25
Enter two number: 50 55large no is =55
0 comments:
Post a Comment