Wap to use Ternary Operator in Java

 import java.util.Scanner;

class Ternary

{

public static void main(String []arg)

{

Scanner scanner = new Scanner(System.in);

int feb;

System.out.print("Enter the no of days in February month:");

feb =scanner.nextInt();

System.out.println((feb==28) ? "The is a Leap Year" : "This is not a Leap Year");

}

}

Comments

Popular posts from this blog

Completed Certification from J.P. Morgan - Software Engineering Job Simulation

Wap to Use Increment And Decrement Operator In Java