Question

I have this method here:

public void returnCoreUnitsForProgram( int index )
{   
    if ( ProgramArray.get(index).getProgramMajor().equals("Software Technology") )
    {        
     /*for(int i = 0; i< size of getUnitType.equals("Core"); i++)*/                        
       for(int i = 0; i< UnitArray.size(); i++)
       {
            System.out.println( UnitArray.get(i).getUnitName() );
       }                
    }                
}

As stated in the comment line I need to loop through the size of the getter method getUnitType().

The purpose is to narrow down the displayed units to those with only the Unit Type "Core".

I tried:

i < UnitArray.get(i).getUnitType().equals("Core")

and

UnitArray.get(i).getUnitType().equals("Core").size()

and of course it failed - miserably.

I'm stuck at this part here. Any pointers guys?

Was it helpful?

Solution

May be this will work for you

public void returnCoreUnitsForProgram( int index )
{   
    if (ProgramArray.get(index).getProgramMajor().equals("Software Technology"))
    {                      
       for(int i = 0; i< UnitArray.size(); i++)
       {
           if (UnitArray.get(i).getUnitType().equals("Core"))
               System.out.println( UnitArray.get(i).getUnitName() );
       }                
    }                
}

equals() returns boolean value not an array/list so you were using it wrong way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top