Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDITED (a third time!): Now that you've posted your code, I've confirmed that my answer below is correct. Tl;dr - you're trying to use head.object before it's been set. What you should be passing in to pickUp is a string that represents the name of the object you want to pick up. For example, head.pickUp("ball");</p> <hr> <p>It would help if you could clarify a bit more what you mean by "not working" - however, it looks like you've got a sort of chicken-and-egg problem here:</p> <p>If I'm reading this right, your code looks something like this? (Including the entire class in your comment might help)</p> <pre><code>public class Head { String object; public void pickUp(String object) { this.object = object; System.out.println("Picked up "+object); } } public class SomeOtherClass { Head head = new Head(); public void pickup() { head.pickUp(head.object); } } </code></pre> <p>EDITED (again) for clarity - It looks like you're trying to use the pickup function (the one in SomeOtherClass) to define the object property of your head. However, by calling it with head.object, you assume that head.object is already defined. Where are you actually setting the string you want to use? </p> <p>It's not really clear what you're trying to accomplish here - but you might want to try either 1) setting head.object in a constructor in your head class. or 2) calling head.pickUp with a string other than head.object (which hasn't been set yet). - Try replacing head.object with "Hello World", for starters. Or, if I've totally misunderstood your intent, perhaps give us a bit more context?</p> <p>EDITED - because I realized that your pickup function wasn't in Head.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload