Old access modifiers persisting after recompile

Hello,
I was following the Sun Tutorials for beginners and got to the exercise about developing Card and Deck classes (http://java.sun.com/docs/books/tutorial/java/javaOO/QandE/creating-answers.html). To see if I understood the concepts about access modifiers I tried tinkering with the supplied answers, Card.java and DisplayDeck.java.
I did the following:
1) In Card.java, changed the class constant, DIAMONDS to private.
2) Recompiled Card.java.
3) Ran DisplayDeck, which uses Card.DIAMONDS.
I did not get a run-time error. I don't understand why. Doesn't DisplayDeck.class use the latest Card.class file? Apparently not. I tried restarting my DOS session and running again. Still no error. Does DisplayDeck.class somehow keep its own version of the Card class until you recompile DisplayDeck?
4) Then I recompiled DisplayDeck and got a compile error. This I understand.
Thanks.
John

Ontological wrote:
Thanks. Is the Bytecode the .class file? Are you saying that when you compile class B, which uses class A, that all constants from class A are stored in the Bytecode for class B?One way to work around this is to use a static initializer. This way the values are not determined at compile time, so they can't be put into dependent classes. I don't really care for this though. I'd just rather recompile everything.
public class Constants {
  public static final int X;
  public static final int Y;
  static {
    X = 123;
    Y = 456;
}

Similar Messages

  • Unable to access/modify wifi after Mavericks installation on MacBook Pro

    I've just installed Mavericks OS X on my 2011 MacBook Pro. Although quite slow, everything seemed to go smoothly during the installation process. Once booted up in the new OS, I noticed immediately that I had no wifi connection on the device. I am unable to enable/disable the wifi, and more troubling, any attempt to make changes to Network settings seems to freeze up the System Preferences application. Once this occurs, the machine is basically useless. A series of restarts, shut downs, safe-mode boot ups, etc and eventually I was just getting a blank grey screen after startup (no login screen, mouse visible and working). At this point, I booted via the recovery partition and did a full re-install of the Mavericks OS X. Not surprisingly, it did not fix any of the problems.

    Very strange problem (no surprise to you).
    I suggest you reset the SMC (and PRAM, if you are able). That cannot hurt and might help.
    Barry

  • No keyboard access in bootcamp after upgrade to Early 2008 MacBook Pro

    How do I regain keyboard access in Bootcamp after a hardware upgrade to a new (early 2008) 15" MacBook Pro (MBP)?
    I was recently forced to upgrade from a July 2007 MBP 15" to an early 2008 MBP due to a burglary. The original MBP also had a Bootcamp partition in use for business purposes (Windows XP SP2).
    Fortunately using Time Capsule and WinClone I had very recent back ups of all data and migration to the new MBP went well until I encountered an insurmountable problem at the point I wished to update the new MPB Bootcamp drivers in the restored Bootcamp partition.
    The problem being encountered is as follows:
    When starting up in the restored Bootcamp partition I am unable to update the with the latest Bootcamp drivers as the keyboard is inoperative. I am therefore unable to get past the CtrlAltDel security pane and navigate to load the Leopard install disk.
    I do however have mouse control.
    I have also tried rebooting with an external keyboard and mouse. Again the mouse worked but not the keyboard.
    To add further confusion or insight into this problem I had a BartPE Windows CD utility disk set-up available for emergency use and this will boot on the new MBP. Once booted it does provide mouse and keyboard access suggesting that somehow in the WinClone restoring process the original keyboard driver was damaged.
    This may well be the case as when I first started up the Bootcamp partition after the restore I encountered a Windows 'blue screen of death' that pointed to a Driver fault in a file called "bcmw15.sys".
    After restarting Windows I no longer encountered the blue screen but had no keyboard access as described above.
    Unforunately using the BartPE CD to bypass the keyboard problem has thwarted me as this configuration does not appear to have a means available to eject the BartPE CD itself, allowing me to then insert the Leopard install disk in its place.
    Given the unique nature of the Windows system configuration I had in use any suggestions as to how I might overcome this without having to resort to rebuilding the configuration from scratch would be gratefully received.
    In particular if anyone may know of the MacBook Pro Windows keyboard driver name and location this would be of particular assistance.
    Dion

    Booting from the Windows Install CD did not work.
    I have however recovered the partition and got operational again.
    The solution in the end was achieved by gaining access via Windows XP start-up in 'safe mode' using an external MS USB keyboard (the new MBP 'delete' key was not being recognised, and then using the 'Administrator' password to gain access to the Windows XP 'Device Manager'.
    The full saga of difficulties encountered is too lengthy to relate in full unless someone out there really wants to know the gory details for their own specific similar need.
    Suffice it to say that the most of the problems that arose were:
    a) the result of the hardware changes between the old MBP and the new one requiring select old drivers to be located and removed and then new drivers installed;
    b) due to an upgrade that occurred to the MS Enterprise server software in the period between when the WinClone image was taken and when the new MPB arrived and I attempted the restore (including that as a consequence of the burglary I updated my corporate mailbox password online causing the back-up XP image to be out of sync with Enterprise server once networking was revived); and
    c) a Parallels software upgrade reinstall also caused issues in regaining sync with the revived Bootcamp.
    Isolating the driver causing the offending ""bcmw15.sys" driver crash proved very tricky as Windows appeared to keep reinstalling some sort of generic driver that kept repeating the problem. Thereafter getting past the blocks to accessing the Apple install CD also required enormous trial and error skill to overcome.
    Bottom line WinClone did perform. It restored the partition on the new machine with sufficient integrity to allow a skilled Sys Op (far beyond my Win experience) the capability to fully restore Bootcamp XP functionality.
    Nevertheless the process is definitely not one I'd prefer to experience a repeat of - its taken several man days (and nights) to resolve.
    Nevertheless thanks xnav for your advice.
    Regards
    Dion

  • Default class access modifier

    What is the default access modifier for a class? I can't seem to find it in the tutorials...
    Thanks
    Jim

    The default access is the same for top level classes that do not specify access explicitly as for other identifiers. Package.
    This single source file will create two class files in the same package. Only other classes in the package can see these top level package access classes.
    And, yes, this is a bad idea. In the case of some build tools, errors in a compile can cause the public class to compile, but the package class to fail. After that, the compiler will not be able to determine what source file to compile for the package level class. This is an error that confuses many developers. I do not recommend this practice. Put each top level class in its own source file.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • SharedObject not persistant after App update (iOS)

    So I have some data stored in a SO. When I explicitly close the app (using double click on home button and closing from the bottom list of icons) the SO persists after reopening the app.
    But when I upload the app to the device after compilation with a new version, SO gets deleted...
    I'm using an ad-hoc profile for enterprise deployment, with Air 3.4 and iOS6.
    The filename and content are the same in the app xml...

    You may want to go through this technote by Apple:
    http://developer.apple.com/library/ios/#technotes/tn2285/_index.html#//apple_ref/doc/uid/D TS40011323
    Apple recommends that for testing update scenarios,
    "Install an ad hoc build of the update through iTunes on a device that already has the old version of the app installed. (from AppStore)
    Do not use Xcode to install or run updates to your app for quality assurance testing."

  • After upgrading to Mountain Lion I am not able to access "security and privacy" button under "system preferences". I like to activate "find my mac" but cannot access privacy setting after upgrade. Kindly advice.

    After upgrading to Mountain Lion I am not able to access "security and privacy" button under "system preferences". I like to activate "find my mac" but cannot access privacy setting after upgrade. Kindly advice.

  • I am unable to access my account after the start up of my pc

    I am unable to access my account after the pc start up even as an administrator. Other account users are able to.

    Passwords are case sensitive and an numeric 0 is often mistaken for an alpha O.  Please verify your entry.
    If unable see here, click the down arrow on the right hand side and select Windows 7
    We are aware that there is a problem with this update concerning the Memphis S motherboard.
     http://windows.microsoft.com/en-us/windows/what-do-forget-windows-password#1TC=windows-7
    Please mark my post as SOLVED if it has resolved your problem. It helps others with similar situations.

  • I think I forgot to make a back up copy of bookmarks while using my old firefox. Recetly after formating my PC, I am unable to get my old bookmark. Pls Help

    forgot to make a back up copy of bookmarks while using my old firefox. Recetly after formating my PC, I am unable to get my old bookmark. Pls Help

    Sorry for your loss. I don't know how we can help you.

  • Why can't I access my music after updating to iOS 5?

    why can't I access my music after updating to iOS 5?

    Same problem here. After installing iOS 5, restoring, and syncing... when I clicked on the music icon on my iPad, none of my songs were there. All I saw was "download music from iTunes store." But, on iTunes, when I clicked on my iPad icon (then Music), it showed that all of my songs were synced!
    So, this is what worked for me, I rebooted my iPad.
    I turned off my iPad by holding down the sleep button for about 5 seconds, then the "Slide to power off" came up, and I powered off my iPad.
    Then, I started it up again, and clicked on the music icon on my iPad, and now all of my synced music showed up.
    I hope this helps some of you guys out there.

  • My old computer died just after I transferred iTunes via external HD.  When I transferred the content from the HD to the new computer, most songs won't play.  Message is "Can't identify source".  Sharing was on in the old computer when it died.

    My old computer died just after I transferred iTunes via external HD.  When I transferred the content from the HD to the new computer, most songs won't play.  Message is "Can't identify source".  Sharing was on in the old computer when it died.

    Is there no ANSWER TO THIS PROBLEM?

  • I am adopting my daughter's old macbook pro  laptop after my laptop crashed. Do I simply restore her old laptop to my latest backup? Will it update her old laptop to my user info?

    I am adopting my daughter's old macbook pro  laptop after my laptop crashed. Do I simply restore her old laptop to my latest backup? Will it update her old laptop to my user info? MacbookPro OSX 10.9.4, restoring from Timecapsule

    Use these guidelines:
    http://www.thesafemac.com/how-to-prepare-your-mac-for-sale/
    This will insure that the Mac is totally yours with any imprint from your daughter.
    Ciao.

  • How do i get my old firefox bookmarks back after uninstalling firefox

    how do i get my old firefox bookmarks back after uninstalling firefox and then reinstalling it from scratch. I did a system restore, but i only retrieved my old tabs, no book marks :(

    Hello,
    see this
    * https://support.mozilla.org/en-US/kb/recover-lost-or-missing-bookmarks?
    * https://support.mozilla.org/en-US/kb/Recovering%20important%20data%20from%20an%20old%20profile

  • Default/package/none access modifier

    Hi,
    I was hoping for some discussion on the default/package/none access modifier. It's always really bugged me that we have public, private, protected, and then "none", while it seems to me that it would be less confusing, and more consistent to use the keyword "package", or maybe even "default".
    Then, source code would look like
    public class MyClass{
        public int getValue() {}
        private void setValue() {}
        protected void someMethod() {}
        package int justForPackage() {}
    }I know this concept has come up before, but the books I've read which mention this topic haven't offered any actaul justification/explanation for why there isn't some keyword.
    Anyway, are there any insights as to why java is this way, and any reasons why java should or shouldn't be changed to include the package access modifier.

    A good example is within a tightly grouped package (usually should be this way) you may have some cooperative classes that access methods.
    // one .java file
    public class SomeHelper {
       private void method() {
         new ClassForUsers().accessHiddenLogic();
    // next .java file in same package
    public ClassForUsers {
        /* default-access */ void accessHiddenLogic() {
    }But, you may want to allow users to subclass your ClassForUsers, without giving them access to the hidden logic method directly:
    // another .java file in a different package
    public class UsersSubclass extends ClassForUsers {
        public void userMethod() {
            // can't do this
            accessHiddenLogic();
    }This could be for either business logic or security reasons. So, package level access can be very useful. However, I've seen that in practice it is avoided because it isn't obvious what is going on.

  • Itunes is showing accessing itunes store after waiting for 30 minutes also

    itunes is showing accessing itunes store after waiting for 30 minutes also

    With those symptoms (assuming you're getting this on iTunes for Windows), I'd try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

  • Java class access modifiers

    Why java class cannot have private and protected access modifiers?

    class X {
      private class y {}
    }should compile just fine. A top-level private class makes no sense because you wouldn't be able to see it. As for protected, I don't know.

Maybe you are looking for