Buggy code:
public class Exercise { public String name ; public String description ; public Integer calories ; public String injuries ; public String equipment ; public Integer time ; public String id ; public Float met ; public String intensity ; public String typeOfExercise ; public String getName ( ) { } public void setName ( String name ) { } public String getDescription ( ) { } public void setDescription ( String description ) { } public Integer getCalories ( ) { } public void setCalories ( Integer calories ) { } public String getEquipment ( ) { } public void setEquipment ( String equipment ) { } public String getInjuries ( ) { } public void setInjuries ( String injuries ) { } public String getId ( ) { } public void setId ( String id ) { } public Integer getTime ( ) { } public void setTime ( Integer time ) { } public Float getMet ( ) { } public void setMet ( Float met ) { } public String getIntensity ( ) { } public void setIntensity ( String intensity ) { } public String getTypeOfExercise ( ) { } public void setTypeOfExercise ( String typeOfExercise ) { } public static List < Exercise > parseOwlResults ( Set < OWLNamedIndividual > individuals , OWLOntology ontology , User user ) { List < Exercise > exercises = new ArrayList < Exercise > ( ) ; ShortFormProvider shortFormProvider = new SimpleShortFormProvider ( ) ; if ( ( individuals != null ) && ( ! ( individuals . isEmpty ( ) ) ) ) { for ( OWLNamedIndividual individual : individuals ) { Exercise exercise = new Exercise ( ) ; exercise . setId ( individual . toStringID ( ) ) ; exercise . setName ( shortFormProvider . getShortForm ( individual ) . replace ( "_" , "<seq2seq4repair_space>" ) ) ; String ns = "http:////www.semanticweb.org//larakellett//ontologies//2015//1//exercise#" ; OWLDataFactory df = ontology . getOWLOntologyManager ( ) . getOWLDataFactory ( ) ; OWLDataProperty description = df . getOWLDataProperty ( IRI . create ( ( ns + "description" ) ) ) ; OWLDataProperty met = df . getOWLDataProperty ( IRI . create ( ( ns + "metabolicEquivalent" ) ) ) ; OWLObjectProperty avoidIfHadInjury = df . getOWLObjectProperty ( IRI . create ( ( ns + "avoidIfHadInjury" ) ) ) ; OWLObjectProperty isOfType = df . getOWLObjectProperty ( IRI . create ( ( ns + "isOfType" ) ) ) ; OWLObjectProperty requiresEquipment = df . getOWLObjectProperty ( IRI . create ( ( ns + "requiresEquipment" ) ) ) ; for ( OWLLiteral lit : EntitySearcher . getDataPropertyValues ( individual , description , ontology ) ) { exercise . setDescription ( lit . getLiteral ( ) ) ; } for ( OWLLiteral lit : EntitySearcher . getDataPropertyValues ( individual , met , ontology ) ) { Float metVal = Float . parseFloat ( lit . getLiteral ( ) ) ; exercise . setMet ( metVal ) ; exercise . setIntensity ( Intensity . findIntensity ( metVal ) . getName ( ) ) ; if ( ( user . time ) != null ) { exercise . setCalories ( exercise . getCalories ( user , metVal ) ) ; exercise . setTime ( user . time ) ; } else if ( ( user . calories ) != null ) { exercise . setCalories ( user . calories ) ; exercise . setTimeCalc ( user , metVal ) ; } } StringBuilder injuries = new StringBuilder ( ) ; int i = 0 ; for ( OWLIndividual related : EntitySearcher . getObjectPropertyValues ( individual , avoidIfHadInjury , ontology ) ) { if ( i > 0 ) { injuries . append ( ",<seq2seq4repair_space>" ) ; } if ( related . isNamed ( ) ) { injuries . append ( shortFormProvider . getShortForm ( ( ( OWLNamedIndividual ) ( related ) ) ) . replace ( "_" , "<seq2seq4repair_space>" ) ) ; i ++ ; } } exercise . setInjuries ( injuries . toString ( ) ) ; StringBuilder equipment = new StringBuilder ( ) ; int j = 0 ; for ( OWLIndividual equip : EntitySearcher . getObjectPropertyValues ( individual , requiresEquipment , ontology ) ) { if ( j > 0 ) { equipment . append ( ",<seq2seq4repair_space>" ) ; } if ( equip . isNamed ( ) ) { equipment . append ( shortFormProvider . getShortForm ( ( ( OWLNamedIndividual ) ( equip ) ) ) . replace ( "_" , "<seq2seq4repair_space>" ) ) ; j ++ ; } } exercise . setEquipment ( equipment . toString ( ) ) ; StringBuilder typeVal = new StringBuilder ( ) ; int k = 0 ; for ( OWLIndividual type : EntitySearcher . getObjectPropertyValues ( individual , isOfType , ontology ) ) { if ( k > 0 ) { typeVal . append ( ",<seq2seq4repair_space>" ) ; } if ( type . isNamed ( ) ) { typeVal . append ( shortFormProvider . getShortForm ( ( ( OWLNamedIndividual ) ( type ) ) ) . replace ( "_" , "<seq2seq4repair_space>" ) ) ; <START_BUG> j ++ ; <END_BUG> } } exercise . setTypeOfExercise ( typeVal . toString ( ) ) ; exercises . add ( exercise ) ; } } Collections . sort ( exercises , new Comparator < Exercise > ( ) { @ Override public int compare ( Exercise e1 , Exercise e2 ) { return ( e1 . met ) > ( e2 . met ) ? - 1 : 1 ; } } ) ; return exercises ; } public Integer getCalories ( User user , Float met ) { } public void setTimeCalc ( User user , Float met ) { } public Double getBMR ( User user ) { } @ Override public String toString ( ) { } @ Override public boolean equals ( Object o ) { } @ Override public int hashCode ( ) { } }

Fix:
k ++ ;