{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

C void mainstring args int x10 y20 return

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t.println("returnArray: "+returnArray[i]); } } //”x” value is copied to the “a” // parameter and ”y” value is // copied to “b” parameter int s1=swap(x,y); System.out.println("x: "+x+" y: "+y+" x +y: "+s1); } } temp=a+b; public sta.c void main(String args) { int x=10, y=20; //return local variable is ok as a new //copy of the value is returned return temp; } Java Objects public class Tester int[2] { 10 numbers public sta.c void main(String 20 args) numbers2 { int numbers=new int[2]; • Java compiler manipulates object references, int numbers2=numbers; instead of object itself for computa.on. numbers[0]=10; • This is more efficient. numbers[1]=20; • Assignment operator (=) : copy the System.out.println("array[0]:” reference value; + numbers2[0]+" array[1]: ” + • Method passed the object argument by numbers2[1]); a copy of the object reference; } • When an object is returned from a method, a copy of the object reference } is returned. 1 10/2/12 Java Parameter Variable is Pass by Value – ArrayList Object Variables public class Tester { sta.c ArrayList<Integer>...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online