So are we creating an instance for a class domestically? - Becaus main is defined in the same class..
Based on what you taught, this is best and simplest i could come up with:
import java.util.*;
public class ArrayL
{
public void Numberinglist(ArrayListCollection<Integer> list)
{
list.add(1);
list.add(2);
}
public static void main(String[] args)
{
ArrayListCollection<Integer> list = new ArrayListCollection<Integer>();
ArrayL l = new ArrayL();
l.Numberinglist(list);
}
}
Still error:
cannot find symbol
symbol: class ArrayListCollection
location: class ArrayL
Something is really wrong.
Apparently i dont work in java, so i dont have a system available @ office.. im practicing online on this:
Java Online Compiler & Runner
-> Do u think something wrong with this cloud app?
Regards and thanks,
KSR
--- Update ---
anybody??
--- Update ---
--- Update ---
Correct code:
import java.util.*;
public class ArrayL
{
public void Numberinglist(ArrayList<Integer> list)
{
list.add(1);
list.add(2);
}
public static void main(String[] args)
{
ArrayList<Integer> list = new ArrayList<Integer>();
ArrayL l = new ArrayL();
l.Numberinglist(list);
int total = 0;
Iterator<Integer> iter = list.iterator();
while (iter.hasNext())
{
Integer val = iter.next();
total = total + val;
}
System.out.println("The total amount is " +total);
}
}
Thankyou so much for all help!
Regards,
KS