r/javahelp • u/[deleted] • Mar 07 '20
New to java, and need some help.
Hey boys, im pretty new to java and im just trying to fix this no-arg constructor compile error.
-----------------------------------------------------------
src\com\rs2hd\model\NPCDrop.java:13: error: missing method body, or declare abstract
public NPCDrop()
----------------------------------------------------------
Here is the code.
----------------------------------------------------------
package com.rs2hd.model;
import com.rs2hd.util.XStreamUtil;
import com.rs2hd.util.log.Logger;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NPCDrop {
public NPCDrop();public static Map<Integer, NPCDrop> npcDrops = new HashMap<Integer, NPCDrop>();
@>SuppressWarnings("unchecked")
public static void load() throws FileNotFoundException {
List<NPCDrop> list = (List<NPCDrop>) XStreamUtil.getXStream().fromXML(new FileInputStream("data/npcDrops.xml"));
for (NPCDrop drop : list) {
npcDrops.put(drop.getNpc(), drop);
}
Logger.getInstance().info("Loaded " + npcDrops.size() + " npc drops.");
}
public static NPCDrop forId(int id) {
return npcDrops.get(id);
}
public class Drop {
private int chance;
private Item[] items;
public int getChance() {
return chance;
}
public Item[] getItems() {
return items;
}
}
private int npc;
private Drop[] drops;
public int getNpc() {
return npc;
}
public Drop[] getDrops() {
return drops;
}
}
--------------------------------------------------------------------
If you can provide an insight that would be fantastic, thank you.
2
u/[deleted] Mar 07 '20
and are you saying the
" public NPCDrop(); " is invalid syntax?