Im new in JAVA language... But I need help urgently in this code now.. I got these errors:
Exception in thread "main" java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:1838)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecim al.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at Library.Main.loadMembers(Main.java:994)
at Library.Main.main(Main.java:40)
when i compile these codes:
public static void main(String[] args) throws IOException{ boolean save = false; DisplayMenu(); String pathPrefix = getPathPrefix(); Library library = loadLibrary(pathPrefix); (Main.java:40) Member[] members = loadMembers(pathPrefix); Book[] books = loadBooks(pathPrefix); if(askpassword (library)){ save = MainMenu(pathPrefix, library, members, books); } else System.out.println("Password invalid. Please try again."); if(save) saveProject(pathPrefix, library, members, books); System.exit(0); } public static Member[] loadMembers(String pathPrefix) throws IOException{ SAXBuilder builder = new SAXBuilder(); String path = pathPrefix + "libraryMembers.xml"; File memberXMLFile = new File(path); while (! memberXMLFile.exists()){ path = askForFile(path,"Members XML File"); memberXMLFile = new File(path); } try{ Document document = (Document) builder.build(memberXMLFile); Element rootNode = document.getRootElement(); List list = rootNode.getChildren("member"); Member[] members = new Member[list.size()+10]; //initialize entire member array for (int i = 0; i < members.length; i++) members[i] = new Member(); for (int i = 0; i < list.size(); i++){ Element node = (Element) list.get(i); members[i].setisSet(); members[i].setfName(node.getChildText("fname")); members[i].setlName(node.getChildText("lname")); members[i].setAdd(node.getChildText("Add")); members[i].setPhone(node.getChildText("Phone")); members[i].seteMail(node.getChildText("eMail")); //members[i].setRestrictedTo(node.getChildText("restrictedTo")); members[i].setmemberStatus(node.getChildText("memberStatus")); members[i].setBirthday(node.getChildText("Birthday")); (Main.java:994) members[i].setfine(Double.parseDouble(node.getChildText("fine"))); members[i].setspeFine(Double.parseDouble(node.getChildText("speFines"))); //members[i].setCheckBooks(Integer.parseInt(node.getChildText("checkedBooks"))); //set checkedbooks String checkedBooksString = node.getChildText("Check Books"); String[] checkedBooksStringArray = checkedBooksString.split(","); int[] checkedBooks = new int[checkedBooksStringArray.length]; for (int checkedBook = 0; checkedBook < checkedBooksStringArray.length; checkedBook++){ if (checkedBooksStringArray[checkedBook].equals("")) continue; else checkedBooks[checkedBook] = Integer.parseInt(checkedBooksStringArray[checkedBook]); } members[i].setcheckBooks(checkedBooks); } return members; } catch (JDOMException jdomex) { System.out.println(jdomex.getMessage()); } return null; }
Need help!!! Your help will be appreciate