public void printSource()
inside a static function like main
public static void main(String args[])
{
printSource();
}
without changing printSource to static???




Posted 19 September 2008 - 10:45 AM
public void printSource()
public static void main(String args[])
{
printSource();
}
Posted 19 September 2008 - 11:28 AM
// Our class is named Main
public class Main {
// this is method for instances of Main
public void printSource() {
System.out.println("Static is bad.");
}
// This is a static or class method
// in this case, the entry point for a Java program
// This is the only method that ever needs to be static.
public static void main (String[] args) {
// create an instance of the class this static method
// belongs to
Main pgm = new Main();
// now use object methods as you like.
pgm.printSource();
}
}
Posted 19 September 2008 - 02:03 PM
baavgai, on 19 Sep, 2008 - 11:28 AM, said:
// Our class is named Main
public class Main {
// this is method for instances of Main
public void printSource() {
System.out.println("Static is bad.");
}
// This is a static or class method
// in this case, the entry point for a Java program
// This is the only method that ever needs to be static.
public static void main (String[] args) {
// create an instance of the class this static method
// belongs to
Main pgm = new Main();
// now use object methods as you like.
pgm.printSource();
}
}
Posted 20 September 2008 - 06:43 AM
Posted 20 September 2008 - 07:21 AM
Programmist, on 20 Sep, 2008 - 09:43 AM, said:
Programmist, on 20 Sep, 2008 - 09:43 AM, said:
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
