Results 1 to 2 of 2
  1. #1
    Moondazz is offline Member
    Join Date
    Jun 2013
    Rep Power

    Default java.lang.nullpointerexception when using maps with arraylist

    I have posted this question in another site also, since I am desperately looking for help with this issue. Im a beginner in Java and I have created the following program, where the operations is class which consists of different fields and acts like a struct in C. The code is as follows:

    Java Code:
    public class operations extends DefFunctionHandler {  
        public Integer stre;  
        public Integer functii;  
        public String nmee;  
        public Integer funcigroup;  
        public Integer sourcee;  
    public void execute(String x) {  
         ArrayList<operations> ops= new ArrayList<operations>();  
         for(int i=0; i< functi.size();i++){  
             operations op = new operations();  
             op.stre = str.get(i);  
             op.functii = functi.get(i);  
             op.funcigroup = functigroup.get(i);  
             op.nmee = nme.get(i);  
             op.sourcee = src.get(i);  
         Map<ArrayList<String>,ArrayList<operations>> obs = new HashMap<ArrayList<String>, ArrayList<operations>>();  
         obs.put(nme, ops);  
         for(operations o: obs.get(x)){  
    I get a nullpointexception error on the line for(operations o : obs.get(x)). Can anyone tell me what the problem is?
    Last edited by Moondazz; 06-12-2013 at 05:22 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: java.lang.nullpointerexception when using maps with arraylist

    Cross posted
    java.lang.nullpointerexception when using maps with arraylist (Beginning Java forum at JavaRanch)

    Did also cross post an earlier related question on the Ranch and SO.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Java.lang.NullPointerException at
    By bmbsage in forum Advanced Java
    Replies: 2
    Last Post: 05-24-2012, 10:38 AM
  2. Replies: 15
    Last Post: 01-13-2011, 06:28 PM
  3. java.lang.NullPointerException
    By peterhabe in forum New To Java
    Replies: 5
    Last Post: 08-27-2010, 08:43 PM
  4. java.lang.NullPointerException
    By vasavi.singh in forum New To Java
    Replies: 3
    Last Post: 02-28-2009, 05:41 AM
  5. Replies: 1
    Last Post: 07-16-2007, 06:32 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts