0

Hi
Im am bigginer in java and i want to know :If a,b are variables of integer type and S1,S2 are variables of Student,what does mean a=b, si=s2. Is any change in way how the value pass in these examples??

I am waiting for a response
best regards Eda

4
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by ash.28.88
0

,what does mean a=b, si=s2

The value of the variable to the right of the = is copied to the variable to the left of the =. Now both variables have the same value.

0

but is there any diference between te way that pass a primitive and reference variable?

0

The assignment statements work the same way for primitives and objects.

What do you mean by pass? Can you give an example?

0

a and b are int variables. Their values are integers.
a=b means that the integer value of b is copied into a, so they now both have the same integer value.
S1 and S2 are reference variables. Their values are references to Objects of type Student.
S1=S2 means that the value of S2 is copied into S1, so they now both refer to the same Student object.

0

a=b and si=s2....
a=b mean if b hold any value such as b=10,then value of b is assign to a.it mean a also holds the value 10.
si=s2 mean si take reference of s2 to hold the value which is hold by s2....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.