import java.util.*;

public class List
{
    public static INode head;
    public List()
    {
        head = new INode(8);

    }
    public static void main (String[] args)
    {
        INode a = new INode(8);
        int data = a.getValue();
        System.out.println(data);
        System.out.println(head.getValue());
    }


}

And my Node class:

public class INode
    {
        private int value;
        private INode right, down;
        private int row, col;

        public INode(int value)
        {
            this.value = value;
        }

        public int getValue() 
        {
            return value;
        }

        public void setValue(int value) 
        {
            this.value = value;
        }

        public INode getRight() 
        {
            return right;
        }

        public void setRight(INode right) 
        {
            this.right = right;
        }

        public INode getDown() 
        {
            return down;
        }

        public void setDown(INode down)
        {
            this.down = down;
        }

        public int getRow() 
        {
            return row;
        }

        public void setRow(int row) 
        {
            this.row = row;
        }

        public int getCol() 
        {
            return col;
        }

        public void setCol(int col) 
        {
            this.col = col;
        }


    }

Yea, head give me null, while a give me 8... can someone explains it to me?

because you haven't called the constructor of your class, which means that your head list never gets instantiated either.

you haven't make object(instantiated) your class List, so your head variable is not initialized.

make object of that class with constructor.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.