0

When we tried to run the following program then it successfully runs.

class with {
    public static void main(String args[]) {
        System.out.println("With static");
    }
}

but even if we tried to run the following program it did't ran successfully.

class without {
    public void main(String args[]) {
        System.out.println("With static");
    }
}

we know becuase in this program we have't use static in main() method. So, we want to ask that the : - is it possible to run java program without static ? if is it possible then how can i do this.

2

2 Answers 2

0

No that is not possible.

Why?

The first method (main) needs to be static, i.e context-free.

You cannot start your program with already instanciated objects, variables, etc...

Sign up to request clarification or add additional context in comments.

1 Comment

what is mean by instanciated objects
0

No.

To run without static, you'd first have to have an object to invoke that method from (using new). Where would you put the instruction to create that object? In a non-static method? That needs an object to invoke that from... Where would you put the instruction to create that object? In a non-static method? That needs an object to invoke that from... Where would you put the instruction to create that object? In a non-static method? That needs an object to invoke that from...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.