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..




On Jan 12, 2006, at 6:56 PM, Matt wrote:


Michael Hall wrote:

On Jan 12, 2006, at 5:15 PM, Bob Irving wrote:

From the java.lang API...


java.lang is a package not a class.

public static String toString(long i)


I assume the Class API you mean is for Long then you want Long.toString(orderID);

The static indicates this is a class method, which can be invoked
without obtaining a actual instance by prefixing the class name.
Otherwise, for a instance method, you would need something like
Long l = new Long();
long whatever = l.toString();

Could you elaborate on those two lines please?


Slapped together usage meant to illustrate the difference between a class method and instance method. Thank you for pointing out the invalid return, an inaccuracy. I myself would cut myself slack as far as demonstrating the point with a no args constructor when none exists for that actual class.
I would think it more confusing for instructional purposes to have said say, ...
long l = (long)0;
Long instance = new Long(l);
String value = instance.toString(l);


less clear to my thinking for the first two lines.
Although I think the above is code that actually would compile and run. e.g.


dojava
long l = (long)0;
Long instance = new Long(l);
String value = instance.toString(l);
System.out.println(value);
12 Jan 2006 19:08:07,263 INFO - RuntimeExecutable: java
12 Jan 2006 19:08:07,303 INFO - -cp
12 Jan 2006 19:08:07,338 INFO - /tmp
12 Jan 2006 19:08:07,385 INFO - jfoo.Dojava52853
0
12 Jan 2006 19:08:08,537 INFO - Runner - [1] org.cmdline.cmds.dojava complete
dojava: done


and shows that a static method can be invoked with an instance object although not invoked from an instance method if I remember right.

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



_______________________________________________
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>)



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.