How do I add this to an arraylist within a static method?
I'm learning the ropes with Java and I've hit a snag with ArrayLists. The gist of my program is to take some user input parameters, create a class Foo with those parameters, and then add it to an arraylist. The problem is, it complains that I can't reference a non-static type from a static method. The only examples I can find online deal with adding constants ("Cat", "5.0" etc) to arraylists which doesn't really help me.   

I put the gist of my code below. I've moved the arraylist off to its own class Bar and added an add method which just does arraylist.add(foo), if only as a crapshoot to make it work (it doesn't). I omitted the loop but it loops a number of times after the definitions, so the arraylist gets populated. 

    public class MainClass{

    public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a, b;

    a = scanner.nextint();
    b = scanner.nextint();

    Foo foo = new Foo(a, b);
    Bar.add(foo); //Complains here
    }
    }

If it helps, the object foo isn't changed after creation. 

How do I get around this? Thanks in advance for any help.

How do I add this to an arraylist within a static method?
===

I'm learning the ropes with Java and I've hit a snag with ArrayLists. The gist of my program is to take some user input parameters, create a class Foo with those parameters, and then add it to an arraylist. The problem is, it complains that I can't reference a non-static type from a static method. The only examples I can find online deal with adding constants ("Cat", "5.0" etc) to arraylists which doesn't really help me.   

I put the gist of my code below. I've moved the arraylist off to its own class Bar and added an add method which just does arraylist.add(foo), if only as a crapshoot to make it work (it doesn't). I omitted the loop but it loops a number of times after the definitions, so the arraylist gets populated. 

    public class MainClass{

    public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a, b;

    a = scanner.nextint();
    b = scanner.nextint();

    Foo foo = new Foo(a, b);
    Bar.add(foo); //Complains here
    }
    }

If it helps, the object foo isn't changed after creation. 

How do I get around this? Thanks in advance for any help.
