<code>
class Init
{
System.out.println("Initializer");
}
class Init1
{
public static void main(
String args[])
{
Init i=new Init();
}
}
</code>
if I compile the above mentioned class, I get the following compile-time error.
Init1.java:3: <identifier> expected
System.out.println("Initializer");
Init1.java:3: cannot resolve symbol
symbol : class out
location: class java.lang.System
System.out.println("Initializer");
But if I place the initilizer part in braces, I don't any errors and the program works well. Can anyone explain the reason behind it.
<code>
class Init
{
{System.out.println("Initializer");}
}
class Init1
{
public static void main(String args[])
{
Init i=new Init();
}
}
</code>