File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java" Watch "Java" New topic


Sumesh Kumar T N

Joined: Jan 26, 2005
Posts: 10
public class Hello {
public static Hello() {

public static void main(String[] args) {
Hello hello=new Hello();

Is there any problem with this code. What is the significance of a constructor being static
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
It will not work as you cannot have static constructors in Java. A static keyword in a method makes it a member of the class in which it is declared in, so you can call it without making an instance of that object. A constructor initializes the new instance to be created, so it doesn't make sense to make it static.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Yes there is a problem with this code even this post. Please ask this in java general beginner forum.
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Moving to Java in General (Beginner)...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Java
It's not a secret anymore!