greenfoot - Java list! How do I get an object to determine if there is another object -


// test rock         list rocks = getworld().getobjectsat(x , y, rock.class);          /* list class (java.util.list) in java api          * , determine method use 'rocks' list          * determine if there rock. put correct test          * in 'if()' statement below.          */          if () {             return true;         }          return false; 

have fill in "if()" statement above return true; confused how if statement lst. please help! , send knowledge of how do! thank guys!

if understand correctly, want check if concrete object rock on list 'rocks'. have use method "contains". public boolean list.contains(object o) checks if object 'o' exists on list.

rock myrock = //whatever sentence use create rock you're checking  if (rocks.contains(myrock) {     return true; }  return false; 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -