So I have this class ItemDictionary public ArrayList<Items> weaponItemsDictionary() { which purpose is to add items to the dictionary and returns it ArrayList<Items> weps = new ArrayList<>();
this is a sample weps.add(new Items("Wooden Bow",10,14,'E',"A Simple Bow made out of wood, Unremarkle in any way",50,1,4));
adding an item object System.out.println("Wep at index 1" + weps);
but upon debugging it Wep at index 1[null] its returning null
#ArrayList returning null values
1 messages · Page 1 of 1 (latest)
<@&987246487241105418> please have a look, thanks.
public ArrayList<Items> weaponItemsDictionary() {
ArrayList<Items> weps = new ArrayList<>();
//bows
//materials bow e - c
weps.add(new Items("Wooden Bow",10,14,'E',"A Simple Bow made out of wood, Unremarkle in any way",50,1,4));
System.out.println("Wep at index 1" + weps);
this is the constructor aswel public Items(String weaponName, int weaponDamage, int weaponCridDmg, char weaponRarity,String weaponDesc, int weaponDurability ,int itemType,int itemProbability) {
this.itemType = itemType;
this.weaponName = weaponName;
this.weaponDamage = weaponDamage;
this.weaponCridDmg = weaponCridDmg;
this.weaponRarity = weaponRarity;
this.weaponDurability = weaponDurability;
this.weaponDesc = weaponDesc;
this.itemProbability = itemProbability;
}
Please use this format for posting code:
```java
// Example java program
int value = 5;
System.out.println(value);
```
Which results in:
// Example java program
int value = 5;
System.out.println(value);
For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.
surlyjoe0101_25649 • used /tag id: code
·
ArrayList<Items> weps = new ArrayList<>();
//bows
//materials bow e - c
weps.add(new Items("Wooden Bow",10,14,'E',"A Simple Bow made out of wood, Unremarkle in any way",50,1,4));
System.out.println("Wep at index 1" + weps);
Detected code, here are some useful tools:
[WARNING] The code couldn't end properly...
Problematic source code:
java public ArrayList<Items> weaponItemsDictionary() {
ArrayList<Items> weps = new ArrayList<>();
//bows
//materials bow e - c
weps.add(new Items("Wooden Bow",10,14,'E',"A Simple Bow made out of wood, Unremarkle in any way",50,1,4));
System.out.println("Wep at index 1" + weps);```
Cause:
The code doesn't compile:
';' expected
illegal start of expression
cannot find symbol
symbol: class ArrayList
location: class
cannot find symbol
symbol: class Items
location: class
cannot find symbol
symbol: variable java
location: class
cannot find symbol
symbol: class ArrayList
location: class
cannot find symbol
symbol: class Items
location: class
cannot find symbol
symbol: class ArrayList
location: class
cannot find symbol
symbol: class Items
location: class
missing return statement
## System out
[Nothing]
java public Items(String weaponName, int weaponDamage, int weaponCridDmg, char weaponRarity,String weaponDesc, int weaponDurability ,int itemType,int itemProbability) { this.itemType = itemType; this.weaponName = weaponName; this.weaponDamage = weaponDamage; this.weaponCridDmg = weaponCridDmg; this.weaponRarity = weaponRarity; this.weaponDurability = weaponDurability; this.weaponDesc = weaponDesc; this.itemProbability = itemProbability; }
i also overloaded the items class object to fit different items
might also be the reason?
java weps.add(new Items("bow", "basic-bow", 3, 1));
i tested to add
to the arraylist using
the other constructor
and it works
hmm
naw im dum