I am trying to use BlueJ to debug my java code for my homework. I am trying to pass arraylist to one of the methods and part of code (relevant) is posted under. Code compiles fine but when I try to create an object instance and input the string arraylist it is not working. I guess I need to know how to input data (parametric) into blueJ prompts when using an arraylist.
I wish I could attach the snapshots of the errors but this forum blocks them. I will try to attach them again anyway to see if that works somehow. I have tried to input in a few different ways but I always get one or the other error in BlueJ, sample of error messages as below:
BlueJ error:
a)
"Error: illegal initializer for java.util.ArrayList<java.lang.String>"
OR
b)
"Error: <identifier> Expected"
Code Snippet:
[highlight=java] import java.util.ArrayList; public class ArrayListMethods { ArrayList<String> list; //instance variable public ArrayListMethods(ArrayList<String> arrayList) { list = new ArrayList<String>(); } public boolean isSorted() { boolean sorted = false; for (int i = 0; i < list.size()-1; i++) { if (list.get(i).compareTo(list.get(i+1)) > 0) { sorted = true; } } return sorted; } } [/highlight]