Friday 15 April 2011

java - what is a temporary variable -



java - what is a temporary variable -

how come when write code 'number' in method stored 'temporary value'? first time have came across this.

what advantage? what disadvantage? why happen?

package lecture18;

public class temporaryvariable { public static void main(string[] args) { int number= 4; number++; system.out.println(number); add(number); system.out.println("but actual value stored in memory is:"+ number); } public static void add(int number) { number = 17; system.out.println("this number using method " +number); } }

java methods nested temporary-objects

No comments:

Post a Comment