"Learn how to check for leap years in Java with this easy-to-follow tutorial! In this video, we'll walk you through a simple Java program to determine whether a given year is a leap year or not. Whether you're a Java beginner or looking to refresh your skills, this tutorial is perfect for you. 🔍✨
👉 What you'll learn:
Basics of Java programming
Conditions and if-else statements
How to check for leap years using Java
📘 Java Leap Year Checker Code:
java
Copy code
// Java program to check leap year
import java.util.Scanner;
public class LeapYear {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Year: ");
int year = sc.nextInt();
if (isLeapYear(year)) {
System.out.println(year + " is Leap Year");
}else{
System.out.println(year + " is not Leap Year");
}
}
static boolean isLeapYear(int year){
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
return true;
}
return false;
}
}
👍 If you found this video helpful, don't forget to like, share, and subscribe for more Java tutorials!
#JavaTutorial #LeapYear #JavaProgramming #BeginnerTutorial #CodingForBeginners