Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maybe you want something like this</p> <pre><code>public class Offers { public static List&lt;Offer&gt; offers = new ArrayList&lt;Offer&gt;(2000); public Offers() { } public void saveOffers(int id, int item, int amount, int currentAmount, int removedAmount, int price, int type, String owner, boolean completed, int slot) { Offer offer = new Offer(id, item, amount, currentAmount, removedAmount, price, type, owner, completed, slot) offers.add(offer); } } </code></pre> <p>You haven't added any <code>Offer</code>s to the <code>offers</code> list. So you cant change the values. That's why you're getting null. <code>ArrayList&lt;&gt;(2000)</code> doesnt add 2000 Offers, just creates a capacity of 2000. Depending on how you define <code>Offer</code> class and it's constructors and getter method (if any), you may want something like my code above.</p> <p>To run it</p> <pre><code>public class TestOffers { public static void main(String[] args){ Offers offers = new Offers(); int id = 1; int item = 1; int amount = 1; int currentAmount = 1; int removedAmount = 1; int price = 10; int type =- 1; String owner = "Me"; boolean completed = true; int slot =1; offers.saveOffers(id, item, amount, currentAmount, removedAmount, price, type, owner, completed, slot); for (Offer offer : offers){ System.out.println(offer); } } } </code></pre> <p>You'll also want to override the <code>toString()</code> method in your <code>Offer</code> class, in order to get your desired output when you want to print an <code>offer</code></p> <pre><code>public class Offer { ... @Override public String toString(){ return id + " " + item + " " + amount + " " + price + " " + currentAmount + " " + removedAmount + " " + type + " " + completed + " " + aborted + " " + currentPrice + " " + slot + " " + owner; } } </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.
    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.
 

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