Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: John Cooper   on Feb 28 In Java Category.

  
Question Answered By: Haboos Kauser   on Feb 28

I said if you create any constructor(s).

Try this.

public class  Test {
public Test(int i){
// does nothing
}
public static void main(String[] args) {
// this will not compile
// Test t = new Test();
// you need to use the other constructor
Test t = new Test(1);
t.helloWorld();
}
public void helloWorld(){
System.out.println("hi");
}
}

Share: