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
Win a copy of
Practice Tests for OCP Java 17 Certification Exam (1Z0-829)
this week in the
OCPJP
forum!
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:
Tim Cooke
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Sheriffs:
Rob Spoor
Junilu Lacar
paul wheaton
Saloon Keepers:
Stephan van Hulst
Tim Moores
Tim Holloway
Carey Brown
Scott Selikoff
Bartenders:
Piet Souris
Jj Roberts
fred rosenberger
Forum:
Java in General
Object assignments
jose chiramal
Ranch Hand
Posts: 266
posted 12 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 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Because after t1=t2; both these variables refer to the same object
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Please Explain (Hashcode)
Please Explain
Interface...
equal() and ==
Strings
More...