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 ?
4 odpowiedzi
+ 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");
}
}
+ 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?
+ 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 ");
}
}
}
0
The problem with incorrect characters can occur when copying code from a web page.