Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Normal getters don't take any arguments</p> <p>Try this</p> <pre><code>String s = "hello"; public String message(){ return s; } String[] someArray = { "Great", "World" }; public String[] message2(){ return someArray; } </code></pre> <p>Then this in your <code>main</code></p> <pre><code>Logic logicObject = new Logic(); System.out.print(logicObject.message()); String[] array = logicObject.message2(); for (String s: array){ System.out.print(s + " "); } </code></pre> <p>Since <code>message2()</code> returns a <code>String[]</code>, you want to set it equal to something when calling it <code>String[] array = logicObject.message2();</code></p> <p>When you try and do this</p> <pre><code>System.out.print(logicObject2.someArray()); </code></pre> <p>You get an error because no method <code>someArray()</code> exists. There is an array <code>someArray[]</code> so you could call it like this <code>logicObject.someArray</code>, without the <code>()</code>.</p> <hr> <p><b>List of all errors</b></p> <ul> <li><code>logicObject.message(s);</code> - There is no <code>s</code> declared that you can pass</li> <li><code>logicObject2.someArray(String[] someArray);</code> - There is no <code>someArray()</code> method in your Logic class</li> <li><code>System.out.print(logicObject.message());</code> - <code>message()</code> in your <code>Logic</code> class takes an argument.</li> <li><code>System.out.print(logicObject2.someArray());</code> - There is no <code>someArray()</code> method in your <code>Logic</code> class.</li> </ul> <p><b>Edit: Conventional data <code>Accessor(get)</code> and <code>Mutator(set)</code> method</b></p> <pre><code>public class Logic { private String s = "hello"; private String[] someArray = { "Great", "World" }; // getter method public String getS(){ return s; } // getter method public String[] getSomeArray(){ return someArray; } // setter method public void setS(String s){ this.s = s; } // setter method public void setSomeArray(String[] someArray){ this.someArray = someArray; } } </code></pre>
    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.
 

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