Results 1 to 3 of 3
Thread: object new and pointers error
- 04-06-2010, 05:43 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 15
- Rep Power
- 0
object new and pointers error
I cant seem to find the logical error.:(Java Code:Cheese jack; Cheese monterey = new Cheese ("Monterey"); jack = monterey; System.out.println("Monterey name is " + monterey.getName()); jack.setName("Jack"); System.out.println("Jack name is " + jack.getName()); System.out.println("Monterey name is still " + monterey.getName());
- 04-06-2010, 05:54 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
What happened? Did monterey's name change as well? Think of variables as remote controls. If you and I both have a remote control pointing to the same television/object and I change the channel then 'your' television/object shows a different channel as well (it's the same television/object after all).
kind regards,
Jos
- 04-06-2010, 06:15 PM #3
Member
- Join Date
- Jan 2010
- Posts
- 15
- Rep Power
- 0
Similar Threads
-
Does Java support pointers?
By kthaker in forum New To JavaReplies: 2Last Post: 10-07-2009, 08:16 AM -
pointers and wrapper classes
By becky in forum New To JavaReplies: 11Last Post: 02-07-2009, 03:59 AM -
Error loading object from file : C:\Date.jrxml Jass Report
By cecily in forum JDBCReplies: 2Last Post: 12-03-2008, 11:14 AM -
Java pointers? How to...
By Krooger in forum New To JavaReplies: 4Last Post: 11-04-2008, 08:30 PM -
Pointers
By ravian in forum New To JavaReplies: 5Last Post: 11-28-2007, 01:49 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks