W
W
WannaCreative2016-11-01 22:34:37
Java
WannaCreative, 2016-11-01 22:34:37

Why is NullPointerException [OOP] thrown?

There is a code in the 1st file (Main.java)

public void setGlory(long glory)
    {
        this.glory = glory;
    }

and the code in the second file
Main m;
public Bank() throws InterruptedException, IOException
    {
        this.glory = Main.getGlory();
        System.out.println("Your balance is: $"+money);

        private void depositMoney() throws InterruptedException
    {
        for (int i = 0; i < 10; i++)
        {
            this.glory++;
            System.out.println("Your glory is: ★"+glory);
            Thread.sleep(1000);
        }

        m.setGlory(glory);
    }
    }

After the for loop - an error pops up, I don’t understand why

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
al_gon, 2016-11-01
@WannaCreative

m.setGlory(glory);
m not null?
debug here!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question