...

View Full Version : Define a constructor



Datis
03-30-2012, 05:57 PM
how to create a constructor for our class with no parameters, constructor has to show
Some sentence:
"You are here!"

Fou-Lu
03-30-2012, 06:40 PM
public YourClassName()
{
System.out.println("You are here!");
}

Datis
03-31-2012, 08:10 AM
public YourClassName()
{
System.out.println("You are here!");
}



public class test {

public test () {
System.out.println("You are here!");}

public static void main (String[] args)


{


}

}

I cant print my sentence, why?

Fou-Lu
03-31-2012, 05:31 PM
You haven't invoked the class 'test'. You need to call a new test(); in the main method.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum