Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't ArrayList<>.add() working?

I'm new to Java and I'm currently using Android Studio. I just can't understand why .add isn't working. Subject and Assignments are just custom classes. The issue is that the message "Cannot resolve symbol 'add'" pops up and the whole thing fails. I have imported java.util.ArrayList.

ArrayList<Subject> mSubjects = new ArrayList<Subject>();
Subject cheese = new Subject("Cheese",new Assignment[]{new Assignment("Test 1",1.0f,1.0f,1.0f),new Assignment("Test 2",100f,100f,1.0f)},100f,4.0f);
mSubjects.add(cheese);
like image 264
TheScrub Avatar asked Feb 11 '23 15:02

TheScrub


1 Answers

mSubjects.add(cheese);

put this method in your onCreate method.

like image 184
stinepike Avatar answered Feb 15 '23 11:02

stinepike