I keep getting this error when making a search method in my code to search through string. I have gone through alot of examples trying to fix this but I cant find any. Thank
You are having exception at this line :
for (String item : notes)
notes
is an ArrayList
declared as raw type, although i don't see the declaration i can see this line of initialization:
notes = new ArrayList();
which sees it's element as of type Object
You need to declare notes
with ArrayList<String>
type such as:
ArrayList<String> notes = new ArrayList<>();
You don't declare the notes variable
public class Notebook{
private ArrayList<String> notes;
...
try this: notes = new ArrayList<String>();
Add notes as a global variable to your class
public class Notebook{
ArrayList<String> notes = null;
....
}
In the constructor, do:
public Notebook()
{
notes = new ArrayList<String>();
}