On Sat, Aug 19, 2017 at 1:42 AM, Stefan Ram <r...@zedat.fu-berlin.de> wrote: > Chris Angelico <ros...@gmail.com> writes: >>On Sat, Aug 19, 2017 at 12:43 AM, Stefan Ram <r...@zedat.fu-berlin.de> wrote: >>>{ final java.lang.Object object = new java.lang.Object(); >>> java.lang.System.out.println( object ); } > ... >> You pass the >>object, not the address of the object. > > Yes, it's true, sometimes you can see it this way. But then, > one can also look at > > public final class Main > { > private static void method( final java.lang.Object parameter ) > { if( parameter == null ) > java.lang.System.out.println( "Not received any object." ); } > > public static void main( final java.lang.String[] args ) > { > method( java.lang.Math.random() > 0.5 ? args : null ); }} > > Here the parameter contains an object only with a probability > of 50 %. How do you call that which is passed otherwise?
Wrong. Your parameter always contains an object. Sometimes that object is an array, sometimes that object is null. Null is not the absence of an object, any more than zero is the absence of a number, or black is the absence of an image. > So, when one is writing »"abc".length()«, by /the language > reference/, »"abc"« is a "reference to an object", and not an > object. > > Your description might be appropriate for Python, but it > cannot describe completely the behavior of the example Java > program given above and it does not use the terms as the > Java Language Reference is using them. Yes, it's a reference to an object. But you are printing out the object itself. Names refer to objects; objects get manipulated. > And when you speak of objects, then after > >>>> class example( object ): > ... def __init__( self ): > ... self.v = 1; > ... >>>> example = example() >>>> a = example >>>> b = example >>>> a.v = 2 >>>> b.v > 2 > > you should say that the variables »a« and »b« now contain > the same object. I /can/ accept this, but some people cannot > accept the idea of the same object being in two places > (variables). (Yes, I know that one usually uses the idea of > "binding" to mitigate this.) The names a and b now refer to the same object. Or are bound to the same object. Either way. ChrisA -- https://mail.python.org/mailman/listinfo/python-list