Acessing object initialization from another class

So I want to be able to use objects in the main class through starting a method from another class. I have this so far. Can anyone tell me what I'm doing wrong or if its possible in another way?

public class main extends index {

    public static void main(String []args) {

public class index {

    public static void index() {
        list object1 = new list(val1, val2);

public class list {

    private static int val1;
    private static int val2;

    public list(val1, val2) {
        //setters and getters look like this for both val1 and val2

        public static int getVal1() {
            return val1;

        public void setVal1(int val1) {
            this.val1 = val;

im also a novice programmer , if i can suggest you, better you assign a variable as result from the invoked method . for example ,

private bool a;

which then u can assign a as true or false when event triggered returns value that u want .

 a = object1.getVal1(#passing param whatever u want);

then u can print the value directly


Hope this helps you.