Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Help coderanch get a
new server
by contributing to the
fundraiser
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
Java in General
Object assignments
jose chiramal
Ranch Hand
Posts: 266
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class Test7 { int a; int b; Test7(int a, int b) { this.a=a; this.b=b; } public static void main(String[] arguments) { int a = 1,b=2; Test7 t1 = new Test7(a,b); int a1 = 3,b1=4; Test7 t2 = new Test7(a1,b1); System.out.println("t1: " + t1.a + ", " + t1.b); System.out.println("t2: " + t2.a + ", " + t2.b); System.out.println("t1 equals t2 ???" + t1.equals(t2)); System.out.println("t1 == t2 ???" + (t1==t2)); t1=t2; t2.a = 100; t2.b = 100; System.out.println("t1: " + t1.a + ", " + t1.b); // am changing only the value for t2, why does the value for t1 also change ? System.out.println("t2: " + t2.a + ", " + t2.b); System.out.println("t1 equals t2 ???" + t1.equals(t2)); System.out.println("t1 == t2 ???" + (t1==t2)); } }
Manish Singh
Ranch Hand
Posts: 160
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Because after t1=t2; both these variables refer to the same object
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Please Explain (Hashcode)
Please Explain
Interface...
equal() and ==
Strings
More...