Nested Java methods -


earlier in code call method

public static boolean divides(int num, int denom) {     if (num%denom==0)        return true;     else return false;  } 

later calling method

public static boolean isleapyear(int year)

i want call divides in isleapyear. have define divides on again? right have

public static boolean isleapyear(int year) { public static boolean divides(int num, int denom) {    if (divides.class == true && (year%400 ==0) || ((year%4==0)         && (year%100 !=0)));        return true;        else return false; } 

}

and error divides defined, when don't put whole public static etc. statement in there wonders divides is.

i'm getting host of other errors (such not being able find year's type after nest divides), that's not main one.

you cannot nest method declarations. however, can define them separately , call 1 other. purpose of functions.

public static boolean divides(int num, int denom) {     if (num%denom==0)        return true;     else return false;  }  public static boolean isleapyear(int year) {     return divided(x, y);  // not sure trying divide, fill in x , y. } 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -