I was messing around with my new knowlage of OOP and...

...well, the whole program works in its confusing web-like self, but I was trying to run a for loop on methodcount(), and make it count from the JavaIsAwsome class, when I run it, everything counts and works fine, EXCEPT the JavaIsAwsome methodcount() thing.
Yes this program is pointless, but it's helping me learn OOP. :)
public class OOP{
     public static void main(String [] args){
          class HelloOOP{
               int oopint = 27700;
          HelloOOP hop = new HelloOOP();
          SomeVars sv = new SomeVars();
          JavaIsAwsome jia = new JavaIsAwsome();
          System.out.println(hop.oopint);
          System.out.println(jia.dude);
          System.out.println("Old : "+sv.methodvar);
          for(int x = 0; x < 100; x++){
               sv.methodcount();
          System.out.println("New Main : "+sv.methodvar);
          jia.counter();
          System.out.println(jia.counted);
          System.out.println("New Main Count : "+jia.mcount);
          System.out.println(sv.methodvar);
class SomeVars{
     int time;
     int methodvar = 10;
     void methodcount(){
          methodvar++;
class JavaIsAwsome{
     SomeVars sv = new SomeVars();
     String dude = "Objects Rock!";
     int counted;
     int mcount = sv.methodvar;
     void counter(){
          for(sv.time = 0; sv.time < 27700; sv.time++){
               counted++;
               mcount++;
               sv.methodcount();
}

Why do you say it doesn't work? I believe it does what the code your wrote tells it to do. I am guessing that you think the methodvar in the SomeVars class should reflect the combination of JavaIsAwesome.counter() method and the methodcount() call from the main method of OOP.
If that's what you don't understand, then considerr that methodvar is an instance variable. The means that each instance of SomeVars has its own copy of a variable named methodvar. So the new SomeVars() in the main method references a different instance of SomeVars compared to the new SomeVars() in the JavaIsAwesome class. Since these are different, changes you make to one do not impact the other.
If you want to share the methodvar between all instances of a class, declare the variable to be static - which in java means belonging to the class.

Similar Messages

  • I was messing around with .kext files in the MacintoshHD and now my MacBook Pro won't start up.

    I was messing around with .kext files in the MacintoshHD and moved the system.kext and two others to my desktop and deleted the originals and now the MacBook Pro won't start up. All I get at start up is the apple icon then a bunch of text shows up part of which says Mac OS version: not yet set. then the apple icon turns into the power icon and tells me to turn off the computer. I've tried reinstalling from the install DVD by holding down option when powering on and selecting the install DVD and it just goes to a white screen with the apple icon and stays like that. I didn't have the disk utility on my Mac before this happened because I deleted it to make room on my computer a while ago so I'm not sure if that's why it won't load the install DVD but anyone who knows the solution to this with out going to get it repaired would be greatly appreciated. Thank you!

    Never mind my dad just found the original install DVD and that worked. Before I was using an install disc that Apple sent me for another issue I was having, but thanks for replying so quickly and trying to help on this Thanksgiving day!!!

  • I was messing around with my iPad and put in a in app purchese and forgot the pass code help!

    I was messing around with my iPad and put in a in app purchese and forgot the pass code help!

    Do you mean you forgot the passcode for your iPad?  If so you need to restore it through the recovery mode described in http://support.apple.com/kb/HT1808

  • Hi, I was messing around with iTunes

    Hi,
    I was messing around with Itunes and did something( Idon't know what) and managed to dramatically lose 3/4 of the albums I previously had.
    Can amyone explain how to recover these lost albums?
    Kind regards,
    Tim

    Restore them from the backup of your hard drive you made prior to "messing around with iTunes".

  • I was messing around with find my iPhone I was prancing my friends but I accede toy locked my phone I don't know how to in lock it the screen is black and I can't get it to turn on and it's still receives cals and text I just can't see cause the screen i

    I was meeting around with lock my iPhone and I was prancing my friends when i locked my phone now it's locked and the screen is now pitch black it can receive calls nut I can't see a thing

    There is nothing that you can do to get rid of the balance on your own. Contact iTunes Store Support and seek their assistance. I believe that they can reset your balance for you.
    https://expresslane.apple.com/Issues.action

  • I was playing around with the size of my window and now I can't get it back to the standard size, any suggestions?

    I was playing aaroound with the size of my window and now I can't get it back to standard size. Any suggestions?

    If you're using Lion, you can resize by dragging from any corner, in Leopard and lower it can only be resized from the bottom right hand corner.

  • Help me please I really messed up,I was messing around with my fathers MacBook Pro 5,4 Intel Core2Duo 2.5Ghz and I deleted the recovery partition aswel as anything else left on the drive,so now when it starts or turns on all I see is a folder with a Quest

    Ive wipped everything off my Fathers MacBook Pro's drive, there's no recovery partition left nothing the model is a MacBook Pro 5,4 Intel Core2Duo 2.5Ghz
    and I don't no were to start to install another operating system Im told this system can't be rebooted only can be booted from the recovery partition,Im really stuck here with this Mac and all it does is show me a Folder with a Question Mark on the screen any help would be appreciated Oh please anything.....I combed threw past post's but Im not to savy on getting around in these forums since this is the first Ive posted to even if there's a link to the way Im going to have to get this reinstalled that would be great I don't know heck Ill download a torrent file of what I need to get started on this any thing you good people tell me I should do,to get this up and running Ill do,please.
    Thanks myklthebrain

    Oh, the irony of referring to yourself as "myklthebrain".  Make an appointment, at the nearest Apple store, with an Apple Genius, and hope that (s)he can sort it out.

  • I was messing around with features to what they did.  now I have a white screen. Can I undo this?

    Hi all i'm brand new to mac. I was checking out features on the system to see what they do. I came to the disk readibility feature where i could determine if it read or read and write etc. im not sure what i did but upon exiting i was locked out ( a red minus displayed on the icon) of my hard rive contents. I couldnt even see what storage space was available etc... i freaked out and restarted the computer, now I have a white screen. How do i fix this?

    Information. If you live near an Apple Store, you can make a Genius Bar appointment.
    Startup Issues - Resolve
    Startup Issues - Resolve (2)
    Genius Bar Reservation

  • I was messing around with my find my iPhone app but I have an iPad .so I looked so find myself and it showed my iPad .where I was. But it said iPad of someone. (That person was not me but my cousin. How can I fix that.

    I need help . My find my iPhone  app has a different name under it. I have and iPad

    Touch or tap the field that you want to use/select and it should get a box around it ; then double-tap that field to activate/type it. Once you've entered your password you can do the same (i.e. touch to select, double-tap to activate) to gradually get into  Settings > General > Accessibility > VoiceOver and turn it off.
    So to enter your passcode you first need to tap the 'slide to unlock' button to hightlight it (it should get a box around it), then double-tap it to unlock it. Then for your passcode tap the digit that you want and it should get a box around it; then double-tap that digit to type it; and similar for the other three digits in your passcode.
    The manual (http://support.apple.com/manuals/#ipad) also that you should be able to switch voice-over off by connecting to your computer's iTunes :
    Turn VoiceOver on or off in iTunes: Select iPad in the iTunes sidebar. In the Options section of the Summary pane, click Configure Universal Access. Select VoiceOver, then click OK.
    So select Configure Universal Access at the bottom of the Summary tab and set Seeing to Neither

  • I was fooling around with the "reader" feature on my New iPad. I am now stuck with that and can't get out. Even my four digit code is read out in a machine voice and the iPad wont boot. How do I get out of this. Tried the red arrow slider. shut of the iPa

    I was fooling around with the "reader" feature on my New iPad. I am now stuck with that and can't get out. Even my four digit code is read out in a machine voice and the iPad wont boot. How do I get out of this. Tried the red arrow slider. shut of the iPa

    James,
    I cannot get into Settings! It keeps reading out Slide to Unlock when I try to slide teh arrow to open the fpur digit entry boxes.

  • I was messing arouond with the general settings and I turned on the voice (under General settings) and when the screen timed out, I can't get it to take my 4 number passcode to get into my ipad.  Please help!  I'm totally locked out!

    I would appreciate any help I can get.  I was just messing around with the general setting on the ipad (64GB 3G...1st edition ipad), and did not realize that if I went under the general settings and changed the option to turn "on" the voice over, that it would require a double click on everything automatically.  I have my ipad set up to lock after 2 minutes on non-use, and when I tried to sign back in, it said that my 4 digit passcode was incorrect.  Then I tried to double click on each number, and that didn't seem to work.  The numbers 1-9 seemed to input ok, but a zero seemed to throw it off.  I have no idea if it has anything to do with it, but any help on getting back in to my ipad, I would greatly appreciate it, and I will be turning off that stupid voice over off as soon as I can.  I was just goofing off, and was not going to let it stay on permenantely, but I tried to go back under the settings immediately, and I couldn't easily find it, but if someone could help on just getting me back in....I would owe you a big favor!
    Thanks......freaking out in Mobile, AL!! 

    Touch or tap the field that you want to use/select and it should get a box around it ; then double-tap that field to activate/type it. Once you've entered your password you can do the same (i.e. touch to select, double-tap to activate) to gradually get into  Settings > General > Accessibility > VoiceOver and turn it off.
    So to enter your passcode you first need to tap the 'slide to unlock' button to hightlight it (it should get a box around it), then double-tap it to unlock it. Then for your passcode tap the digit that you want and it should get a box around it; then double-tap that digit to type it; and similar for the other three digits in your passcode.
    The manual (http://support.apple.com/manuals/#ipad) also that you should be able to switch voice-over off by connecting to your computer's iTunes :
    Turn VoiceOver on or off in iTunes: Select iPad in the iTunes sidebar. In the Options section of the Summary pane, click Configure Universal Access. Select VoiceOver, then click OK.
    So select Configure Universal Access at the bottom of the Summary tab and set Seeing to Neither

  • Iphone contacts "not available" to car phonebook after messing around with Outlook.pst file names and backups. Iphone4 connects to car though and other phones connect properly.

    iphone contacts "not available" to car phonebook after messing around with Outlook.pst files, names and backups, on my ms XP 2003 laptop. I substituted a much smaller new Personal Folder -Contacts File, with a smaller list of phone numbers (4 only as a test) which successfully synced to the iPhone 4. The iPhone connects to the Skoda Octavia HandsFreeSystem OK (Bluetooth works fine), but now iPhone wont load the new Contacts as it did originally. However a family Nokia (never messed with) can connect properly. So must be the iPhone or more likely an Outlook.pst \ Contacts problem. Ideas?

    After fiddling a little more, the following fixed my corrupted outlook.pst file:
    1) I made a backup
    2) In outlook under file, I exported the calendar to excel
    3) In outlook under file, I imported the calendar back to outlook
    And voila, it worked.

  • I have a problem with my motherboard and my battery of my 2010 macbook pro 13". It was just serviced with a new screen, keyboard, and logic board.

    I have a problem with my motherboard and my battery of my 2010 macbook pro 13". It was just serviced with a new screen, keyboard, and logic board. How much will a new battery and motherboard cost and would it be worth it or should I just get a new computer. It was about 300 dollars to get it serviced last week. if it adds up to much past 600 dollars I will just get a new one. THANKS FOR ANY HELP!
    P.S During classes today it began beeping in my bag. Like three kind of long steady beeps then a short pause, and when I opened it I couldn't see anything but it was on so I turned it off and back on.

    Depends on what options your Apple store offers - if they can do a depot repair (where they send it out), that's around $300 for all parts & labor.
    If the store doesn't have that option, a logicboard is around $600, battery $80-$100, from what I've seen.
    If they JUST replaced the logicboard, you absolutely should NOT have to pay for another replacement - the replacement is covered by a warranty. If they want you to pay for it, make sure you have a copy of the receipt for the work that was recently completed so you can show it to them. They have no reason to charge you for another logicboard.
    ~Lyssa

  • Ovi messes around with my .jar files

    Hmm, been unable to find info about this elsewhere.
    When i install the Ovi suite (2.0.1.36) it decides that it is the best default program for my java .jar files which i use on my computer, not my phone.
    Everytime i try to pick the appropriate program for my jar files, it either has errors or doesent show any gui.
    Is there anyway to use the phone tethering without the ovi software or is there a fix to this?

    Yes, this is completely ridiculous. Nokia PC Suite did the same, I expected newer software to stop messing around with something that is a de facto standard: .jar files are Java Archive files. OVI installation should NOT mess with the settings in registry for .jar files.
    Run regedit, and look at the key HKEY_CLASSES_ROOT\.JAR (note the dot befor JAR)
    This is where OVI has messed with things... You will see that the value OVI has set on that key is Nokia Ovi SuiteApplicationInstaller_JAR
    If you have a key on your system that is HKEY_CLASSES_ROOT\jarfile Change the setting on
    HKEY_CLASSES_ROOT\.JAR to jarfile.
    H.

  • Re: My Macbook 2009 model was recently upgraded with a new hard drive and upgraded to Mountain Lion OS. I am battling to retrieve all my photos that were ''saved'' in iCloud. Can someone help?

    Re: My Macbook 2009 model was recently upgraded with a new hard drive and upgraded to Mountain Lion OS. I am battling to retrieve all my photos that were ''saved'' in iCloud. Can someone help?

    If you are trying to recover photo stream photos, they are only held in iCloud for 30 days.  All you would be able ro recover is photo stream photos from the last 30 days.
    If you have an iOS device that still has the photo stream photos one it, you can save them to the camera roll by opening the my photo stream album, tapping Edit, tap the photos, tap Share, tap Save to Camera Roll.  Once in the camera roll, they can be imported to iPhoto on your Mac as explained here: http://support.apple.com/kb/HT4083.

Maybe you are looking for

  • Officejet J5780 all in one

    How many F*&^$*(#$#(*&$#(*& times am I going to have to install the software for this D*#$&#* machine???????????  This is the 6th or 7th time that I've had problems and HP's only solution is "reinstall the software".  The first time, I used the softw

  • Can't print from Word or Acrobat

    OK, I had this problem maybe two years ago and I did fix it. The problem is back and I don't remember how I fixed it. I have an HP printer (new printer since the last time I had this problem so its not necessarily the printer) - MS Word and Acrobat A

  • Keeping keywords and rating 'stars' a permanent part of RAW files

    I store RAW files on a portable HD. I use it for both desktop and laptop. Keywords and rating 'stars' entered on one machine do not appear when using the other. How can i make the keywords and rating 'stars' transferrable from one machine to another?

  • Pl sql - web

    Hi everyone! I am here with another question I have an issue here. Right now, I am displaying a table in the web by selecting all the records from a particular table. This is how I do it. PROCEDURE Alagu_DOWNLOAD_REPORT () is begin Alagu_DOWNLOAD_REP

  • Reconciling bank statements by value date

    Dear gurus!! I wonder if any of you have come across this before. Currently, we are automatically reconciling bank statements only by the amount. However, it has now been required to start using the value date as a reconciliation criterion too along