public class MyClass{
static int staticcounter;
int instancecounter;
public static void main(
String[] args){
for (int i=0;i<5; i++)<br /> new MyClass();<br /> }<br /> }<br /> public MyClass() {<br /> staticcounter++;<br /> instancecounter++;<br /> System.out.println("Static Counter="+staticcounter);<br /> System.out.println("\ninstancecounter="+instancecounter);<br /> }<br /> }<br /> Once I try to compile this program, I get the following message.Compiler wants class keywork with MyClass constructor, But I think that is not the way constructors are declared!!<br /> <br /> C:\jdk1.2.1\bin>javac MyClass.java
MyClass.java:12: 'class' or 'interface' keyword expected.
public MyClass() {
^
MyClass.java:12: Class MyClass already defined in MyClass.java.
public MyClass() {
^
MyClass.java:12: '{' expected.
public MyClass() {
^
3 errors