So i currently have this:
public static JavaFact register(JavaFact jf){
Scanner input = new Scanner(System.in);
Map<String, Activity> activities = new HashMap<String, Activity>();
Map<String, Activity> companyActivities = new HashMap<String, Activity>();
activities = jf.getAllActivities //this is just to get all the existent
// activities into the Map activities
System.out.println("How many activities is the user envolved in?");
int count = input.nextInt();
for(int i = 0; i<count; i++){
System.out.println("Insert activity code");
String code = input.nextLine();
Activity a = activities.get(code);
companyAcitivities.put(code, a.clone()); //the error refers to this line
}
}
With this i'm getting a NullPointerException
after running it on main. How can i solve this? What i want is for the user to insert the code of the Activity
, and then add that Activity
to the companyActivities
wich will be the Map
holding all the activities corresponding to the Company
in question.