Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Errr..



What's your point with this example? It's illegal. There's no explicit instance or implicit 'this' for the invocation of the hello instance method. As I stated instance methods require an object instance.

Don


At 10:29 AM -0600 1/14/06, Michael Hall wrote:
On Jan 14, 2006, at 9:50 AM, Don Bate wrote:

A static method can be invoked from anywhere the class is visible. If the class is not explicitly specified, then it searches the enclosing scopes looking for a suitable match. Instance method require an object instance to invoke including an implicit 'this'. BTW, you _can_ invoke a static using an object instance, the class used is the class of the instance.


public class Foo {

	public static void main(String[] args) {
		hello();
	}

	public void hello() {
		System.out.println("Hello, World!");
	}
}


Mike Hall mikehall at spacestar dot net http://www.spacestar.net/users/mikehall http://sourceforge.net/projects/macnative


--
Don Bate               | Specializing in Consulting and Mentoring in
Bate Consulting, Inc   | Object-Oriented Technologies,
                       | Software Architecture, and Software Process
(972) 618-0208 voice
(972) 618-0216 fax
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Re: Java Swing and Quartz (From: Brian Foster <email@hidden>)
 >Errr.. (From: Bob Irving <email@hidden>)
 >Re: Errr.. (From: Michael Hall <email@hidden>)
 >Re: Errr.. (From: "Matt" <email@hidden>)
 >Re: Errr.. (From: Michael Hall <email@hidden>)
 >Re: Errr.. (From: "Matt" <email@hidden>)
 >Re: Errr.. (From: Michael Hall <email@hidden>)
 >Re: Errr.. (From: Don Bate <email@hidden>)
 >Re: Errr.. (From: Michael Hall <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.