View Single Post
Old 11-04-2003, 01:34 AM   #11 (permalink)
DarkTwilkitri
Registered User
 
Join Date: Feb 2003
Location: Australia
Posts: 21
DarkTwilkitri is on a distinguished road
That sentence is ambiguous, sorry :/

It can be tested simply without having to worry about those pesky nulls.

Code:
public class test
{
    int skasaher;

    test()
    {
        skasaher = 3;
    }
    public void increment(test johan)
    {
        johan.skasaher++;
    }
    public static void main(String[] args)
    {
        test celice = new test();
        System.out.println(celice.skasaher);
        celice.increment(celice);
        System.out.println(celice.skasaher);
    }
}
This prints out 3, 4. Not 3, 3 as it would if the change affected a copied object.

My earlier mis-interpretation of your theory may have been the most correct.
It passes a copy of the reference to the function, so when you set the copy to null, it doesn't affect the original because you are just changing the copied location. But when you change something inside the copy, it is changed.

...Of course, this is all just supposition...


And I was referring to
if(null == a)
when there isn't actually any a to compare against null. I think you meant o.
DarkTwilkitri is offline   Reply With Quote