class B {
void view(){
System.out.println("in class b");
}
}
public class A {
B obj = new B();
obj.view();
}
in this code on the line obj.view there appears an error: syntax error on token view, identifier expected after this token
class B {
void view(){
System.out.println("in class b");
}
}
public class A {
{
B obj = new B();
obj.view();
}
}
but when i put those line in a block like above no compile time error appears there but there appears a run time error;
Error: Main method not found in class A, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
Does it mean that i cannot run code without main method? if i need a main method then why eclipse is not showing any error when i put it in a block