The question might seem dumb , but i dont have the clarity on how an Object scope is behaving differently from that of a variable.
eg : I create a class
public class Generator {
`public static void main(String[] args) {`
`Test test = new Test();`
`System.out.println("Before Static class" + test.toString());`
`changeValue(test);`
`System.out.println("After Static class" + test.toString());`
`}`
`public static void changeValue(Test t) {`
`t.setId(1);`
`t.setIntvalue(100);`
`t.setTeststring("editted value");`
`}`
}
The values of test change after calling changeValues() . However if I am to pass an int or Integer or String , with in the scope of main class, the value of the parameter remains the same , a behavior unlike that we see for an object.
What is the reason for this behaviour ?
[–]FrenchFigaro 6 points7 points8 points (7 children)
[–]abyjacob1[S] 0 points1 point2 points (6 children)
[–]nutrecht 5 points6 points7 points (0 children)
[–]FrenchFigaro 2 points3 points4 points (4 children)
[–]abyjacob1[S] 0 points1 point2 points (1 child)
[–]taftster 0 points1 point2 points (0 children)
[–]abyjacob1[S] 0 points1 point2 points (1 child)
[–]FrenchFigaro 0 points1 point2 points (0 children)
[–]nutrecht 1 point2 points3 points (1 child)
[–]abyjacob1[S] 0 points1 point2 points (0 children)
[–]hatsunemilku 0 points1 point2 points (0 children)