Michael Hall wrote:
>
> 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.
I tend to disagree. What is perhaps more confusing is code which will not
compile - especially when it is intended for instructional purposes.
> and shows that a static method can be invoked with an instance object
> although not invoked from an instance method if I remember right.
You seem to be stating that a static method cannot be invoked from an
instance method. Do you hold true to this statement? In this case, how
would a static method ever be invoked? Would you please provide an example
of this? This time, your example would be expected to fail compilation.
Thanks,
Matt
_______________________________________________
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