Is it OK to use clone when you only need shallow copy?

I created copy contructors for all of my libraries classes because I was afraid of using the clone() method.
However, my copy constructors create shallow copies of the objects - which is probably the same as using clone().
Before I go deleting all the copy constructors from all of my classes...
Is there any reason not to use clone() in this case? Are there any gotchas with clone() when it comes to just a simple shallow copy (perhaps with simple arrays, simple object arrays, or collections) ?
Thanks

Another thing worth mentioning is that if you really need to have more control of the clone process, then just over-ride the clone method. In most cases the default Object.clone() method should be enough. BTW don't forget to use the Clonable interface for your class.
The whole notion of a copy constructor is much more a C++ thing.

Similar Messages

  • Same message every time I open iPhoto - "use iPhoto when you connect..."

    Every time I open iPhoto 6 (using a MacBook Pro) I am asked: "Do you want to use iPhoto when you connect your digital camera?" I respond "yes," only to be presented with the same question the next time I open the program. Any thoughts on why that might be and how I can stop it from asking (and remember that I want to use it with my camera)?
    MacBook Pro (Dual 2.0Ghz)   Mac OS X (10.4.6)  

    Thanks for the suggestion. I gave that a try, but no luck. Turns out, though, my main volume was corrupted--most likely related to running the public beta of Parallels Workstation (great software, but there's a reason they tell you not to run betas on production computers ). I repaired my drive using Disk Utility and that seems to have done the trick.

  • TS3048 how to turn on bluetooth when you only have a wireless mouse and keyboard

    How can you turn on the Bluetooth when you only have a wireless mouse and keyboard?

    Hello:
    Read this (the part about OS X not allowing Bluetooth to be turned off unless a USB mouse is connected):
    http://support.apple.com/kb/TS3048?viewlocale=en_US
    I have an old USB mouse available in case something happens to my BT mouse.
    Barry

  • [svn] 3921: Fix for - @inheritDoc tag not working for get/ set overrides when you only override the setter of a base class

    Revision: 3921
    Author: [email protected]
    Date: 2008-10-28 06:23:00 -0700 (Tue, 28 Oct 2008)
    Log Message:
    Fix for - @inheritDoc tag not working for get/set overrides when you only override the setter of a base class
    QE Notes: Baselines for framework test will need to be updated.
    Doc Notes: None
    Reviewer: Paul
    Bugs: SDK-17304
    tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17304
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ASDocExtension.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java

    Revision: 3921
    Author: [email protected]
    Date: 2008-10-28 06:23:00 -0700 (Tue, 28 Oct 2008)
    Log Message:
    Fix for - @inheritDoc tag not working for get/set overrides when you only override the setter of a base class
    QE Notes: Baselines for framework test will need to be updated.
    Doc Notes: None
    Reviewer: Paul
    Bugs: SDK-17304
    tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17304
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ASDocExtension.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java

  • HT3275 2 problems: All files are locked - how to globally unlock on the backup drive? I am backing up large video files 500GB on a 2 TB machine. Time Machine repeatedly copies everything using up all of disk space. I only need 1 copy not, twenty. What to

    2 problems: All files are locked - how to globally unlock on the backup drive? I am backing up large video files 500GB on a 2 TB machine. Time Machine repeatedly copies everything using up all of disk space. I only need 1 copy not, twenty. What to do?

    2 problems: All files are locked - how to globally unlock on the backup drive? I am backing up large video files 500GB on a 2 TB machine. Time Machine repeatedly copies everything using up all of disk space. I only need 1 copy not, twenty. What to do?

  • I have 19GB of storage.  Why can't I update my iPad to IOS 8 when I only need 4.4 GB of storage?

    I Have 19GB of storage and only need 4.4 GB to update to iOS 8.  It still says I only have 4.9 GB and won't let me update the software.  Why?

    Do you have that 19 gigs on your device (Settings>General>Usage) or is it iCloud space? You need local space to upgrade.

  • How is it possible to use data when you hardly even use your phone?

    I just got an LG G3 phone yesterday afternoon and have 500 mg to use and have already maxed it out and have hardly even used the phone!!!!!!!!!!!!!! It has data been used why I am sleeping and when I know 100% I am not even on my phone. I use my laptop for all internet. My husband doesn't even use the internet, and if he does I am the one that finds the page he needs, and he really doesn't even know how to use it. He has a basic flip top and doesn't want anything more. So, please help me understand how data is being used almost all day, all night, and even when we are sleeping and the phone is not being used for anything? As a matter of fact, I am on my laptop and can't sleep because of this!! My phone is in the other room and I bet data is being used right now. But, I know don't anyone uses that much data in a DAY and A HALF when the phone is not in use. I have had three phone calls all day and only one I answered and I made one call out, but data has been used all day. And I have had free 250 mg for probably at least six months and have used no data and now all the sudden when I have been on my laptop all day the data is used. Can someone please help me understand how this is possible?@

    GZRX wrote:
    Recently came back on Verizon contract cell service after years on various prepaid services. The S5 is my first unrooted smart phone and I am pretty paranoid about data usage as no longer able to use Droidwall and Titanium Backup.
    Phone default settings are Data Off, Playstore set to wifi update only and background data off for many apps. I have "My Verizon My Data app" and "Active Apps" app on home screen for monitoring purposes.  Something seems to infrequently activate the You-Tube and Chrome apps randomly. Cloud is turned off as I back up to Google and my computer. I have a number of other apps turned off as well and monitor "Data Usage" for unwanted app data consumption.  Also have data usage warning and shut off levels set in the phone. My plan is 1 GB and I am regularly using under .5 GB. 
    correction to above: my reference to  "Phone default settings" above is misleading.  That should be my worded as "My current phone settings:"  Unfortunately I am not permitted to edit my previous post.

  • How to upload data using utl_file when you dont know the exact file name

    Hi
    i want to upload data from a flat file to a table.
    i dont know the exact file name. i want to make a search for filename. like i want to make a search on file (say test*) which will give me all the files with test.
    i want to upload data using these files.
    how can i do this by using UTL_FILE.
    Regards
    Manish

    Thank you very much.
    Thing is previously we are using sqlloader and shell script for loading the data.
    now i am creating a procedure (if possible without parameters).
    Is there any other way i can do that.
    can i make a wild card search using utl_file.
    Thanks n Regards
    Manish

  • Publishing a particular Web site using iWeb when you have 2 iWeb projects

    Hi ! I'm a new mac user. Working with iWeb is great. I have 2 web projects. How can I upload or publish 1 of the sites without both of them being uploaded ? Every time I have tried to upload on .Mac, both sites are being uploaded but I only want one of them (the smallest one) to be uploaded. Thanks for the help !

    goony goo goo,
    It can be done, but you need to jump through a few hoops to make it happen. Read through these notes on separate sites, held in individual Domain.sites files in iWeb.
    Mark

  • What uses data when you are actully not using phone?

    Android user here...Grandaughters i-phone 4s seems to use a lot of data. from 12:00am-6:am she used 209mb. She was asleep. Any ideas???

    Check wjosten's first answer as well as the HT4146 article attached here:
    https://discussions.apple.com/thread/4703527?tstart=0

  • Where's a magician when you really need one?

    Recently did a re-install of 10.3.9, but now it's not much fun because Sherlock doesn't work.
    No matter what I enter into the search field, the response of "no results found" stays there. It's almost as though it loads the internet, but can't access information or something prevents it from searching. All the other channels do the same thing.
    Been through the discussion posts and tried deleting various files to no avail.
    Can anyone please suggest something that will work?
    G4 Titanium   Mac OS X (10.3.9)  

    That is a very nice and complete report of your problems and observations.
    Thanks, I'm becoming very intimate with them. ;P
    ... related to having an older
    version of Safari on their machines. I am wondering
    if something similar could be causing you trouble.
    Hard to say.
    All I know is that running Safari 1.3 started off fine, then became progressively worse each time I used it. After the Re-install, I loaded 1.2 and it's been working very well... so I'm cautious about updating it.
    ...start the Console app and make sure
    that the console log file is the one that opens on
    your screen. Then, start Sherlock and do one of the
    things that does not work. When a failure occurs,
    something might be written to that log.
    Nothing written in the first log that appears. However, in the Library log, there is this:
    CurrentSet updated to 0 (Automatic)
    2005-12-19 22:45:34.526 Internet Connect[301] Error: Unable to create connection ref for service id 1
    2005-12-19 23:04:27.473 Sherlock[575] * -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
    2005-12-19 23:04:29.757 Sherlock[575] * -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
    2005-12-20 00:31:55.011 Sherlock[604] * -[NSCFDictionary setObject:forKey:]: attempt to insert nil val
    And about 70 or so instances of this:
    Incorrect start/end range ordering; fixing.
    Range {0x0a4c, 0x0a4c} doesn't map to a codespace range.
    Also an additional 70 or so instances of:
    Can't create CMap Adobe-Identity-UCS2
    And finally:
    Range {0x2c, 0x2c} doesn't map to a codespace range.
    Can't create CMap HANBIT-ForPDF-UCS2.
    Can't create CMap HANBIT-ForPDF-UCS2.
    Can't create CMap HANBIT-ForPDF-UCS2.
    Can't create CMap HANBIT-ForPDF-UCS2.
    z_alloc: 0 bytes in use out of 21392764 bytes overall; max 6442508.
    2005-12-20 16:55:48.944 Sherlock[474] * -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
    2005-12-20 16:55:48.955 Sherlock[474] * -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
    2005-12-20 17:06:40.770 Sherlock[478] * -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
    2005-12-20 17:06:46.866 Sherlock[478] * -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
    2005-12-20 17:32:26.752 Internet Connect[331] Error: Unable to create connection ref for service id 1
    I have no inkling as to what any of that actually means.
    To do this, I would
    need to have the output of your softwareupdate log
    file, from the time that you re-installed 10.3.0 to
    the present (I am assuming that you have used
    Software Update. )
    No.
    After loading 10.3 from the retail kit for the first time, I dowloaded the updates manually from the Apple site (sorry, not very efficient, but I'm fairly new to Panther and didn't know about Software Update).
    I don't know if here was an issue with Sherlock at that point because I didn't launch it.
    After all upgrades were installed, I backed up the downloaded updates onto CD so I would have them in case of emergency. After the Re-install, the updates from 10.3 to 10.3.9 were enabled from the CD. Sherlock is the only app that is not working.
    I will see if I can learn anything.
    I'm very appreciative of the time you're spending on this.
    BTW, I bought and thoroughly ran TechTool 4.1.1 according to the manufacturer's specs. While my machine is now running faster, the annoying problem is still there.
    G4 Titanium   Mac OS X (10.3.9)  

  • How do you stop app's going across 2 iphones when you only have 1 apple ID for itunes?

    I have an iPhone, iPad & iMac which is all set up lovely. However my girlfriend now has a iPhone too so I have set up her phone with my apple ID for itunes but her own one for emails etc.
    The issue I am having is that when ever she down loads an app it appears on my phone as well, how do I stop this my friends think I'm changing my ways with all these girly apps apearing on my phone at random??

    Hi Oxford_lad,
    apart from you treating your girlfriend to well, you just have to deactivate automatic downloading!
    Enabling Automatic Downloads on your iPhone, iPad, or iPod touch
    Tap Settings > iTunes & App Stores on your device.
    Tap Sign In if you're not already signed in to the iTunes Store.
    Enter your Apple ID and password.
    Tap On/Off switch to enable or disable Automatic Downloads for each content type.

  • Need to change my password NOW, and where is a DBA when you really need one

    I'm attempting to teach myself SQL using the book "Murach's Oracle SQL and PL/SQL". They recommended downloading Oracle Express Edition. I downloaded Express Edition 11g. The book says it's applicable with all versions through 11g.
    Anyway, last Sunday I got a warning message, "ORA - 28002: The password will expire within 7 days.
    28002.00000 - "the password will expire within %s days"
    *Cause: The user's account is about to expire and the password needs to be changed
    *Action: change the password or contact the DBA
    Vendor code 28002
    I don't have a DBA; I'm trying to learn this stuff on my own. I've been corresponding with the book's author. He's been having me try different stuff
    (ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
    SELECT PROFILE FROM DBA_USERS WHERE USERNAME = SYSTEM;
    ALTER PROFILE <PROFILE_NAME> LIMIT PASSWORD_LIFE_TIME UNLIMITED; ) None of this worked. He finally wrote that I should access the Database Home Page to change the password for the existing users.
    Problem is, from the Oracle Database 10g Express Edition -> Go to Database Home Page, and that's not an option in my Oracle Database 11g Express Edition; my options are Get Help, Backup Database, Get Started, Restore Database, Run SQL Command Line, Start Database, and Stop Database.
    How can I change my password so my database doesn't lock up? The database is on my home computer, so if I can set it up so there is no password expiration time that would be preferrable.
    Thank you in advance for your help.

    Updating the profile after a password has expired is like closing the barn door after all the cows have left.
    Sure, the new cows won't be able to leave, new users created with the unlimited profile won't get the expired password problem but the 'escaped' cows still need to be fixed. Use a system or /as sysdba connection and set a new value for the user password.
    sqlplus /nolog
    conn /as sysdba
    ... connected ...
    alter user <username> identified by <new password> account unlock;
    conn <username>
    ... password ...
    ... connected ...
    alter user <username> identified by <a different password>;As soon as system (or sysdba) or any user with the DBA role fixes the user account <username> should be good to go. And can set his/her own password as well. Its your database, you get to be the DBA.
    Edited by: clcarter on Dec 3, 2012 12:57 PM
    fix code tag typos

  • Can you create and print a hard cover photo album on iPhoto when you only have a iPad,  can someone please help.  Did not see the option to print.

    I am trying to create and print a hard cover photobook using iPhoto on my iPad, can this be done?  Did not see the option.  Can someone please help?

    It can't be done on the iPad using iPhoto for iOS.  You need to use iPhoto for the Mac.

  • HT3697 I am trying to convert a Keynote Presentation to a cross platform PDF file. When using export it creates a 30mb file when it only need to be 2-3mb and so cant email or use it very easily. How do I get the file size down?

    I'm trying export a Keynote presentation to PDF, or other format, to use on Windows PC, iPad and other devices.
    The file Keynote create is way too large at 30mb+. So cant email or share it very easily
    If I print it and to Adobe PDF I can get it to 3mb, but have to crop it manually, and some settings or graphics are not so good or accdeptable!
    Does anyone know how to do this?

    Use Dropbox to send large files that cant be sent using email:
    https://www.dropbox.com/

Maybe you are looking for

  • Alerts in case of XSLT Mapping failure without BPM

    Dear All, We are working on IDOC - SOAP Scenario and mapping is through XSLT Mapping. when the Vendor number field in IDOC is coming blank/invalid, the mapping should fail and an email alert should go to business. This IDOC-SOAP is Asynchronous and n

  • How to setup Time Capsule for wireless backup only

    I have a new Time Capsule that I want to set up for wireless backups of both my Macbook Air (with Time Machine) and a Windows Vista laptop. I have an existing home wireless network with my Att/Uverse tv and internet service. I do not want to disturb

  • How can i restore my iphone with the data i downloaded 3 times

    how do i restore my iphone i downloaded the restore data 3 times how can i restore my phone with that as i cannot us anymore data

  • How do I import RAW images from Sony NEX 5-R to iPhoto?

    I have Mountain Lion 10.8.2 and iPhoto 9.4.2 and have installed Digital Camera RAW compatability update 4.01 but still can't import RAW images from my new Sony NEX 5-R digital camera.. any ideas? I also have Photoshop CS6 - should I import through th

  • Payslip overlap problem

    Hi All, This is a problem I face in Rem. Statement. If the lines per page is exceeded, then the extra lines get displayed overlapped over the existing lines on the first page. Even on the second page, the lines are displayed over text items instead o