0

class leapyear { public static void main (String args[]] { int year=2016; if(year%4==0) { System.out.println(“The given year is

What is the error in this ?

8th Jan 2025, 10:31 AM
Prem Sharma
Prem Sharma - avatar
4 Respuestas
+ 2
The code cause an error because the "args[]]" has 2 closing square brackets, which should be "args[]" Also the quotation marks used is incorrect, you shouldnt use any other quotation marks even that's the same thing, Java is a case sensitive language, so the code should looks like: class leapyear { public static void main (String args[] ) { int year=2016; if (year%4==0) { System.out.println("The given year is leap year"); } else if (year%4!=0) { System.out.println("The given year is not leap year"); } }
10th Jan 2025, 4:58 AM
☕︎︎AstroParrot✦
☕︎︎AstroParrot✦ - avatar
+ 1
We can't see your code, add it like this: https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app One tip, if it's from a question: are you meant to hard code the year or should it accept input?
8th Jan 2025, 11:57 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
args[]] has one extra parenthesis class leapyear { public static void main (String args[] ) { int year=2016; if (year%4==0) { System.out.println("The given year is "); } } }
8th Jan 2025, 10:49 PM
zemiak
0
The problem with incorrect characters can occur when copying code from a web page.
10th Jan 2025, 8:33 AM
zemiak