can i assign values to null parameters in functions? for example:
i dont know why that wont work.... i assigned it to an instance in the 2nd function, so why would it still be null?? the error i get is the null pointer exception when i try to excute a.method() Thanks for any help provided [ November 18, 2003: Message edited by: Lisa Cook ]
That's why they say that in Java there is only pass by value. When you call the other method, what was passed was the value of your object reference. So what happen was: 1. a = null 2. you passed a copy of a reference to a method 3. that method has it's own 'a'(unfortunate that you pick same name), that has a copy of original 'a' value which is null. 4. You reassign copied 'a' inside the method to an object. Original 'a' still has null value. 5. method exit and object that was referenced by copied 'a' went out of scope 6. original 'a' is still null when you call it. Hope that helps..
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad: