It can be done in C++, can it be done in Java?

Hi
In C++, the following code will change a to 2.
int a = 1;
int *b = &a;
    *b = 2;How can this be done in Java?
My reason is that I implemented SortedSet so that it creates and maintains a binary tree (Assignment pre-requisite).
If the subSet method is called, it returns a portion of the Tree!
How can i get it to return this portion so that any changes which are made to this subSet are automatically reflected in the original Tree? (Just trying to be a geek and get extra brownie points)
Thanx
Tecknick

public class MyInt {
public int sss;
public MyInt myInt = null; // only reference
public MyInt( ){
} // default constructor
} // class MyInt ends here..
// here now..
public MyInt a = new MyInt( );
a.myInt = a; // very Clever
a.sss = 1; // Your ---------------> int a = 1;
public MyInt b = a.myInt; // your
------------------> *b = &a;
b.sss = 2; // Your -----------------> *b = 2;
What is the point of the member field myInt here? The example code gives the effect of just using MyInt myInt = this; and not setting the value in the client code. Why would you ever need to explicitely give an object a reference to itself? You would get exactly the same results (and clearer code) if it wasn't present:
public class MyInt {
  public int value;
  public MyInt(int value) {
    this.value = value;
  public static void main(String[] argv) {
    MyInt a = new MyInt(1);
    a.value = 1;
    MyInt b = a;
    b.value = 2; //Since a == b, a.value is now equal to 2 as well.
}Notice that this is now the same idea as was posted by rabbit3000 earlier - it just doesn't use accessor methods (up to you if you decide you want to) - all it is, is a mutable version ot java.lang.Integer. I couldn't see a good reason for a default constructor, so I took that out too.

Similar Messages

  • I create an apple id then i want to verify it, i verify it once then  when i log in with my apple id it asked mi again to verify it.everytime i log in it asked me to resend verication and after i resend it i press done. Please can anyone help me ?

    I create an apple id then i want to verify it, i verify it once then  when i log in with my apple id it asked mi again to verify it.everytime i log in it asked me to resend verication and after i resend it i press done. Please can anyone help me ?

    How are you verifying it?  Are you responding to the email that is sent?  If not, do so.
    If so, then try changing your password.

  • My Finder is going crazy.  Keep getting a message saying it quit unexpectedly and asking if I want to restore windows, but I can't get it to stop.  buttons don't work.

    My Finder is going crazy.  Keep getting a message saying it quit unexpectedly and asking if I want to restore windows, but I can't get it to stop.  buttons don't work.

    Something else you can try.
    In Finder hold down the option/alt key while selecting the Go menu item. Select Library. Then go to Preferences/com.apple.finder.plist. Move the .plist to your desktop.
    Restart and test. If it works okay, delete the plist from the desktop. 
    If the same, return the .plist to where you got it from, overwriting the newer ones.
    If you want to make your user library permanently visible, run the below command in Applications/Terminal.
    chflags nohidden ~/Library/
    You will need to do that after any updates.

  • How can I make it so that my songs don't go on her iPod and her songs ....

    Me and my mother just got iPods for christmas and hers was a U2 ipod and mine was a 30gb ipod. I have downloaded some songs and have imported some cds but my mother doesn't want those songs on her ipod. How can I make it so that my songs don't go on her iPod and her songs don't go on mine.Do i need to create another itunes?

    The computer can tell the difference between your two iPods. When you first plugged each one in, you named them and the computer recognizes each one as a separate disk.
    Now, when you plug in your iPod, and you are looking in iTunes at your iPod contents, you will see four buttons in the bottom right corner of iTunes - the first one is to display iPod options. Click on this, and under the music tab, select "Automatically update selected playlists only". Then, you scroll through your playlists and select only those you want to be transferred to your iPod. Your mother can do the same thing. Now you can each make your own playlists from the same music library, and only those songs you want to go onto your iPod will transfer when you plug it in. You can make the same selections for all the other options too (video, podcats. photos, etc), so that you only have to have what you want on each iPod.
    I have two iPods, a new 5g video iPod and an ancient 1g iPod, and have no problems syncing each of them with different playlists and options.

  • My wife and i have an iPhone 5 6.1.2 firmware.. We both are having horrible wifi signals.  We have done everything we can.. What update will fix this? I get full bars on my iPad 2 through my whole house.. Be standing right beside the router with iPhone NO

    My wife and i have an iPhone 5 6.1.2 firmware.. We both are having horrible wifi signals.  We have done everything we can.. What update will fix this? I get full bars on my iPad 2 through my whole house.. Be standing right beside the router with iPhones and it cuts in and out.. Drops from 3 wifi bars to 1

    I am having the same problem with brand new Ipad Mini at my house.
    It connects to the WiFi fine - but will not pull an IP address in DHCP mode, or if I set all the IP info statically - it still will not get any network access.
    This doesn't look like a WiFi issue, as it does connect and is seen by the WiFi Access Point.  All the normal WiFi fix stuff doesn't help.
    - Using a Dlink DAP-2553 which is less than 2 months old. 
    Other devices connect fine, including Ipad 2.
    This same Mini worked fine at another house and also connected to a mobile hotspot fine....so seems to be some weird IP issue with maybe this Access Point or maybe the older Router that I have (older Netgear)?
    I am actually a network engineer and still have not been able to find a solution.  Both the Ipad Mini and the Dlink WAP have the latest firmware loaded.
    Wondering if anyone has found a solution to this problem.

  • I recently updated to Firefox 8 and ever since I have done that, I can't get it to open. Every time I click on the icon on my desktop to open it, it crashes. What can I do to fix this?

    I recently updated to Firefox 8 and ever since I have done that, I can't get it to open. Every time I click on the icon on my desktop to open it, it crashes. I have tried all the steps in the Firefox crashes article and I can't figure out what is wrong. How can I fix this?

    please install latest version of Roboform 7.6.2 and try
    * www.roboform.com/support/news

  • I need to change my iCloud email address.  I changed it for my Apple id but I can't log out of iCloud to change it there.  Find my iPad is activated so I can't delete my iCloud account.  I don't have the email address the iCloud login has anymore.

    I need to change my iCloud email address.  I changed it for my Apple id but I can't log out of iCloud to change it there.  Find my iPad is activated so I can't delete my iCloud account.  I don't have the email address the iCloud login has anymore so I can't have the password sent there.  To sum it up, iCloud has an old email for the account log-in.  I don't remember the password for the old email.  I have Find My iPad activated so the iCloud account cannot be deleted.  And I am already logged out of iTunes & App Store. 

    If you mean that Find My Phone is asking for a password to a different Apple ID to your current Apple IDand that ID is a previous version of your current ID, not an entirely different one.
    This feature has been introduced to make stolen phones useless to those that have stolen them.
    However it can also arise when the user has changed their Apple ID details with Apple and not made the same changes to their iCloud account/Find My Phone on their device before upgrading to iOS 7, or if you restore from a previous back up made before you changed your details and some other circumstances.
    The only solution is to change your Apple ID back to its previous state with Apple at My Apple ID using your current password, you don’t need access to this address if it’s previously been used with your Apple ID, once you have saved these details enter the password as requested on your device and then turn off "find my phone" and delete the account from your device. It may take a short while to remove the account.
    You should then change your Apple ID back to its current state, save it once again and then log back in using your current Apple ID. Finally, turn "find my phone" back on once again.
    This article provides more information about Activation Lock.

  • I can't remember my Apple ID password or my security question answers. When I try to reset my password it wants to send it to my e-mail address but I can't get the e-mail because I don't have security answers or the password. How do I reset password?

    I can't remember my Apple ID password or my security question answers. When I try to reset my password it wants to send it to my e-mail address but I can't get the e-mail because I don't know my security answers or the password. How do I reset password?

    Alternatives for Help Resetting Security Questions and/or Rescue Mail
         1. If you have a rescue email address or a Security Questions issue, then see:
             If you forgot the answers to your Apple ID security questions - Apple Support.
             Manage your Apple ID primary, rescue, alternate, and notification email addresses - Apple Support
         2. Fill out and submit this form. Select the topic, Account Security. You must
             have a Rescue Email to use this option.
         3. This is the only option if you do not already have a valid Rescue Email.
             These are telephone numbers for contacting Apple Support in your country.
             Apple ID- Contacting Apple for help with Apple ID account security. Select
             the appropriate country and call. Ask to speak to the Account Security Team.
         4. Account security issues almost always require you to speak directly to an
             Apple representative to securely establish your identity as the account holder.
             You can set it up so that Apple calls you, either immediately or at a time
             convenient to you.
                1. Go to www.apple.com/support.
                2. Choose Contact Support and click Contact Us.
                3. Choose Other Apple ID Topics and choose the appropriate topic for
                    your issue.
                4. Follow the onscreen instructions.
             Note: If you have already forgotten your security questions, then you cannot
             set up a rescue email address in order to reset them. You must set up
             the rescue email address beforehand.
    Your Apple ID: Manage My Apple ID.
                            Apple ID- All about Apple ID security questions.

  • TS3988 My icloud account is not verifying it says check my mail witch I have done and I get a message say your iPhone for has been used to set up and Icloud account but still can not use the icloud can anybody help me.

    My icloud account is not verifying it says check my mail witch I have done and I get a message say your iPhone for has been used to set up and Icloud account but still can not use the icloud can anybody help me.

    Be sure you are checking the email account that you used to set up the Apple ID you used to create the iCloud account.  Also, be sure to check your spam/junk folder as well as your inbox.  The email you should receive looks like the image below.  When you get it, click the Verify Now link.
    If it still isn't there, try going to https://appleid.apple.com, click Manage your Apple ID, sign in, click on Name, ID and Email addresses on the left, then to the right look for a link to resend the verification email.

  • How can I delete my Icloud account when I don't know the password and no longer have the email address associated with it?

    How can I delete my Icloud account when I don't know the password and no longer have the email address associated with it?
    You need your password to delete it and I need the email address to reset the password.  I feel like I'm going in circles!!!  Please help!!!

    Go to https//appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address (you shouldn't need to verify the old account).  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https//appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • I have just download a book from itunes store but, i don't have an iPad to read it. Can anybody help me? Can i convert it? Thanks.

    i have just download a book from itunes store but, since i don't have an iPad, i can´t read it or even see it. Can anybody help me? Can i convert it? Thanks.

    Every purchase page for an ebook has a section that says "Requirements".  What does that say for your particular book?  That should give you the answer to your question.  Conversion is normally not possible.
    But there are some exceptions.  Please provide the Title of the book if you want further help.

  • I have 4 equal oblong shape created with borders How do I go about knowing what size the selection area is so that I can crop an image to fit. I don't want to use paste in then adjust the bounding box to suit

    I have 4 equal oblong shape created with borders How do I go about knowing what size the selection area is so that I can crop an image to fit. I don't want to use paste in then adjust the bounding box to suit

    What do you mean a moderator

  • I just got a new MacBook Pro, and I tried to bring across my files from my last mac using time machine. After it was done copying I can't find my files anywhere but the space (about 130gb) has been used on my hard drive. Help please!!

    I just got a new MacBook Pro, and I tried to bring across my files from my last mac using time machine. After it was done copying I can't find my files anywhere but the space (about 130gb) has been used on my hard drive. Does anyone know how I can get to them? I did change my user name from 'user' while it was copying, could this have something to do with it?

    You don't want to do that by copying.
    Your best bet, by far, is to use Setup Assistant.  If your Mac is running Snow Leopard, see Using Setup Assistant on Snow Leopard or Leopard.
    If it came with Lion, it's a bit different: Using Setup Assistant on Lion

  • App store will not let me download the free Yosemite because a family member has already done so.  Can I get it under family share?

    I went to download the free version of OS X Yosemite, and when I clicked the "free" button a message appears saying that a family member has already downloaded it and the only option I have is to buy it.  Can I access the free version through family share? If i leave family share can I download the free version?

    We don't want you to leave your family!
    I think that the best thing would be preparing an USB loader of the Yosemite installer and then use it for new installation process.

  • I am getting an error message that "A copy of Firefox is already open. Only one copy of Firefox can be open at a time" and I don't have any copy open.

    I am getting an error message that "A copy of Firefox is already open. Only one copy of Firefox can be open at a time" and I don't have any copy open. How do I correct this problem? I really like firefox because it runs many technical programs on the web that do not work with safari. I have FireFox version 32.0.1 installed on my MacPro PowerBook OS X 10.7.5. My activity monitor does not show any FireFox activity, so do not know what it is seeing

    This worked, I used the method described in this link http://forums.mozillazine.org/viewtopic.php?t=365156, and opened the Mozilla profile screen with the terminal on my mac, using the language given in the links. Then I duplicated my original profile to save the bookmarks, etc. Put them in a folder listed Duplicate profile with the date. With the open profile screen, I deleted my original profile, created new profile folder and then a new profile. Note that profile cannot be created in the system library, it must be created on the disc, because the library will not allow writing into it. After I created my new profile folder, I dragged all my old information into it, and it worked. Firefox closed and the error disappeared. You must be VERY careful to make sure Firefox is closed anytime you are doing anything with the profile folders. I think that is what caused my original problem.

  • I downloaded an app off the store which said it was free and part of the 5 year promotion. I've been charged for the app by the store. I don't want the app and there's no one to speak to about it. Who can I call and how can I get the app off my phone?

    I downloaded an app off the store which said it was free and part of the 5 year promotion.
    I've been charged for the app by the store. I don't want the app and there's no one to speak to about it.
    Who can I call?
    How can I get the app off my phone?
    How do I get my money back from something I wouldn't have ordered?

    You cannot call anyone.  You contact them as everyone else does:  http://www.apple.com/support/itunes/contact/
    You delete the app as you do any other app.  Hold an icon until they wiggle.  Tap the "x".  This is covered in the manual.

Maybe you are looking for

  • How to add a DTD Reference to the payload ??

    Hi All, How to add a DTD Reference to the payload using graphical mapping ?? For eg: Current Output ============ <?xml version="1.0" encoding="UTF-8" ?> <dcsextractdata extractname=""> <dataheaders> <dataheader> <record_type datatype="123" /> <action

  • View tiff image

    Hi I download the sample:Image Controls for long raw,Blob and interMedia Image Content on http://otn.oracle.com/sample_code/products/jdev/files/images/sample.html, this sample work fine, but only work with gif & jpeg images. My Database use longraw c

  • Problem installing iLife '08

    I had a 10.5 (latest) Mac with iMovie from iLife '08. THIS MAY BE IRRELEVANT, BUT FOR THE SAKE OF COMPLETION: I ran Migration Assistant to move a number of user accounts, and also brought over applications. Prior to doing so, I placed all the apps on

  • OWA Name Change

    We Currently have a Multi-Tenant exchange 2010 Environment , that we host client tenant's on .We would like to change the external domain address /owa address .Currently our clients use mail.domain.co.za as there server address & the same in http pro

  • System Center Operations Manager 2007

    Hi, Is there anyone who is monitoring their IronPort C-series with System Center Operations Manager 2007? If so, is there anything I should look out for implementing it? /Fredrik