What do you mean by reference in Android?

abhilashts

New member
Jan 3, 2016
0
0
0
what do you mean by reference in android

i am a complete beginner
here is the code

//get a reference to textview
TextView brands=(TextView) findViewbyid(R.id.brands);

//get a reference to spinner
Spinner brands=(Spinner) findViewbyid(R.id.brands);

what is happening in the above code

thank you
 
Re: what do you mean by reference in android

A variable is a named "box" that you put data into.
integer x = 7;
integer y = 4;
x = y; // x got a copy of the data in y

A pointer is a variable that contains the memory address of a variable. This is used to "point at" other variables and change their data.
integer x = 7;
integer & p = null; // points to "nothing"
p = &x // p now points to x
*p = 12; // the contents of what p points to (x) now is 12

A reference is a pointer that cannot point to "nothing". Using a pointer that points to "nothing" will crash the app.
 

Latest posts

Trending Posts

Forum statistics

Threads
956,245
Messages
6,967,187
Members
3,163,493
Latest member
clhjr