Guest_imported
New member
- Jan 1, 1970
- 0
Hi,
I just started learning java and wanted to make a simple program with a main and an init() method. Isn't it possible to start a method from a mainfunction? I'm getting the error: can't make a static reference to method void init()in class Test. Here is the code:
class Test
{
public static void main(String args[])
{
init();
}
public void init()
{
System.out.println("Starting init()"
}
}
So how do I call the method init() without having to erase static from the main?
Thx
Hartge
I just started learning java and wanted to make a simple program with a main and an init() method. Isn't it possible to start a method from a mainfunction? I'm getting the error: can't make a static reference to method void init()in class Test. Here is the code:
class Test
{
public static void main(String args[])
{
init();
}
public void init()
{
System.out.println("Starting init()"
}
}
So how do I call the method init() without having to erase static from the main?
Thx
Hartge