- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Check Leap Year Using Ternary Operator | Beginner Friendly
In this video, I demonstrate a simple Java program to check whether a given year is a leap year or not using logical operators and the ternary operator.
🎯 Purpose of this program
The main goal of this program is to understand how to use conditions and logical operators to solve real-world problems like checking leap years.
💻 Code Explanation
int y = new java.util.Scanner(System.in).nextInt();
➡️ This line takes the year as input from the user using the Scanner class.
boolean leap = (y % 400 == 0) || (y % 4 == 0 && y % 100 != 0);
➡️ This line checks whether the year is a leap year using conditions:
If the year is divisible by 400 → Leap year
OR if divisible by 4 AND not divisible by 100 → Leap year
System.out.println(leap ? "Leap Year" : "Not Leap Year");
➡️ This uses the ternary operator:
If leap is true → prints "Leap Year"
Otherwise → prints "Not Leap Year"
📘 What you will learn
Taking input using Scanner
Using logical operators (&&, ||)
Understanding leap year logic
Using ternary operator in Java
Writing clean and efficient conditions
📌 This is an important beginner-level problem that improves your logical thinking and coding skills.
💡 Learning these conditions helps you solve many real-world programming problems.
Keep learning and building your Java knowledge 🚀
#Java #JavaProgramming #LeapYear #TernaryOperator #BeginnerJava #CodingForBeginners #LearnJava #JavaTutorial #ProgrammingBasics #LogicalOperators #DSA #CodingPractice #SaumizCodex
Видео Check Leap Year Using Ternary Operator | Beginner Friendly канала saumizcodex
🎯 Purpose of this program
The main goal of this program is to understand how to use conditions and logical operators to solve real-world problems like checking leap years.
💻 Code Explanation
int y = new java.util.Scanner(System.in).nextInt();
➡️ This line takes the year as input from the user using the Scanner class.
boolean leap = (y % 400 == 0) || (y % 4 == 0 && y % 100 != 0);
➡️ This line checks whether the year is a leap year using conditions:
If the year is divisible by 400 → Leap year
OR if divisible by 4 AND not divisible by 100 → Leap year
System.out.println(leap ? "Leap Year" : "Not Leap Year");
➡️ This uses the ternary operator:
If leap is true → prints "Leap Year"
Otherwise → prints "Not Leap Year"
📘 What you will learn
Taking input using Scanner
Using logical operators (&&, ||)
Understanding leap year logic
Using ternary operator in Java
Writing clean and efficient conditions
📌 This is an important beginner-level problem that improves your logical thinking and coding skills.
💡 Learning these conditions helps you solve many real-world programming problems.
Keep learning and building your Java knowledge 🚀
#Java #JavaProgramming #LeapYear #TernaryOperator #BeginnerJava #CodingForBeginners #LearnJava #JavaTutorial #ProgrammingBasics #LogicalOperators #DSA #CodingPractice #SaumizCodex
Видео Check Leap Year Using Ternary Operator | Beginner Friendly канала saumizcodex
Комментарии отсутствуют
Информация о видео
26 апреля 2026 г. 6:42:23
00:01:30
Другие видео канала




















