The definition and call of the method with return value

The definition and call of the method with return value

public class HelloWorld{
    
    
    public static void main(String[] args){
    
    
        //isEvevNumber(10);直接用方法名(参数)的方式来接收没有意义,无法输出
        //需要用:数据类型 变量名 = 方法名(参数)
        boolean flag = isEvevNumber(10);
        System.out.println(flag);
    }
    public static boolean isEvevNumber(int number){
    
    
        if(number%2 == 0){
    
    
            return true;
        }else{
    
    
            return false;
        }
    }
}


Guess you like

Origin blog.csdn.net/taoyingle/article/details/115116711