I´m learning java with bluej and it appears "missing return statement"


#1

The exercise is about making a method called getCriticalAge, and it has to appear the age to get 18 if it´s less or if it´s more, the age to get 65 and finally if it´s over 65, how many years has passed since he was 65.

it appears an error "missing return statement".

public int getCriticalAge(int age)
    {
        if( getAge<ADULTHOOD_AGE) return age= (ADULTHOOD_AGE-age);
        
        if (getAge>=ADULTHOOD_AGE) return age= (RETIREMENT_AGE -age);
        
        if (getAge>RETIREMENT_AGE) return age= (age - RETIREMENT_AGE);
    
     
    
    
    }

thanks


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.