Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Beginning Java 2
|
BOOK: Beginning Java 2
This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2004, 01:19 PM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sasman23x
Default Chapter 5 page 196- duplicating objects

Hi there. I simply don;t understand how the exmaple works in the book for duplicating objects. the code is

Sphere(final Sphere oldSphere) {
raduis= oldSphere.radius;
xCenter = oldSphere.xCenter;
yCenter = oldSphere.yCenter;
zCentre = oldSphere.zCenter;

}

I have anumber of questions
1) is this a constructor
2) how manay arguments have been sent to this (as there are no commas is this one or three)
3) why is the word final there?




 
Old January 31st, 2004, 09:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Default

1) Yes, it is a constructor. The fact that it has the same name as the class and doesn't have a return type would indicate this.

2) There is only one argument, it is called oldSphere and its type is a Sphere, which has been declared final.

3) The use of final in this example has been done to ensure that the object reference for oldShpere cannot be modified. It isn't stritcly necessary in an example this trivial, but I'm assuming that Ivor did do so to showcase another use of the final keyword, this time with method parameters and also to indicate good programming style, as he is clearly stating that the original object reference cannot be changed in this constructor.

I hope this helps

Cheers

Martyn





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 - Forms as objects Zave BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 0 August 22nd, 2007 12:23 AM
Passing objects between One Page to next page muralidharan.d ASP.NET 1.0 and 1.1 Basics 2 July 3rd, 2007 07:48 PM
Chapter 10 - building objects kscase BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 5 April 23rd, 2007 04:55 AM
Beginning ASP.NET 2.0 - Chapter 6 - page 196 warren_banks BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 September 2nd, 2006 08:21 AM
Transferring Objects from one page to other page. g_vamsi_krish ASP.NET 1.0 and 1.1 Basics 3 August 31st, 2006 11:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.