Inner class inside a method - how does it access method's local variable?

hello All:
I've learnt that, an inner class, if defined inside a method, it can access the method's local variables, only when they are defined as "final".
Anyone can help explain the rationale behind it?
Thanks a lot!
Sway

fathomBoat wrote:
In java, everything is about pass-by-reference.
Wrong! Nothing in Java is ever pass-by-reference.
Java uses pass-by-value everywhere.
It makes sense to me if the reason of enforcing a variable to be "final" is to prevent it being messed up.No, the reason is that a copy is made and if the variable weren't final then it could change later on and the developer could be confused because his inner class didn't "see" that change.
The variable being final prevents that scenario.
However, if a copy of the variable is made inside the inner class, i dont see how possible it could affect variables outside of class?Such a copy is made, but the language designers wanted to hide that fact from the developer. By forcing all accessed variables to be declared final the developer has no way to realize that he's actually working on a copy.

Similar Messages

  • How does java access user specific environment variables ?

    Hi,
    I'm running a java application on a W2K o/s. My application needs to be able to access the user environment variables in Windows but I don't know how to do this. Can anyone help ?
    Thanks.

    http://www.rgagnon.com/javadetails/java-0150.html

  • HT4914 How does the payment method work for iTunes Match?

    How does the payment method work with iTunes Match. For example, if you have a gift card, does it take it out of that. Or is there tax? What if you cancel your subscription in the middle of the year, does it take the money for that year or not? If someone could answer those questions it would be greatly apreciated. And if anyone has their own questions, feel free to ask. Thank you.

    Hi HLFrank,
    Welcome to Adobe Forum,
    You can opt for monthly payment in a yearly contract or pay at one go for an year.
    Please check the option at http://www.adobe.com/in/products/creativecloud/buying-guide.html
    Regards,
    Rajshree

  • How does the .accept() method work?

    Hi,
    I have checked the source code of the ServerSocket implementation that comes with the jdk.
    I tought I was going to find some type of loop. However I found nothing like that! so how does the accept method work.
    I mean when we call the .accept() method, the thread in which the socketServer is initialized gets stoped untill a new client connection is recieved! how is this actually managed?
    Regards,
    Sim085

    At a guess, the accept call that Java makes, relies on the OS system call through JNI. accept would then block until a new connection is present if you are using blocking.

  • How does the return method work?

    how does the return method work?

    What do you mean by "return method"? Methods return a value (or void, but that's still a "value" of sorts).
    Returning a Value from a Method
    http://java.sun.com/docs/books/tutorial/java/javaOO/methoddecl.html

  • In Photo 1.0, how does one access the map showing where all photos were taken, as could be done previously in iPhoto?

    In Photo 1.0, how does one access the map showing where all photos were taken, as could be done previously in iPhoto?

    Hi JohnDory,
    The information side-bar from iPhoto has been removed in Photos App, and so it's been converted into a pop-up window showing both the exposure, aperture and so technical photo parameters, as well as the comments, faces and LOCATION for that photo.
    This small floating window is shown whenever you click the button in the app title bar, right clicking a specific photo or pressing ⌘i
    If you open the albums view (clicking in the name of the album list, NOT an album name, you can see in your left sidebar - which can be shown or hidden) and press ⌘i without selecting a specific photo the Info pop-up will show the map for your whole library (as well as the total amount of photos, videos, GB used, etc)
    So, I'm afraid the "Locations" view (which I really loved) from iPhoto has been ripped off... and we can only get "some sort of locations view" by this method.
    As for locations... there is no option for manual geotagging (so, setting location to a specific photography which doesn't have it yet)... that really ****** me off 
    Regards,
    braincasualties.

  • How does one access "footers" in Dreamweaver cs6?

    How does one access "footers" in Dreamweaver cs6?

    How does one access "footers" in Dreamweaver cs6?
    Depends on your code.  If your site uses Server-side Includes, it's quite possible the footers are in a separate file in your site folder such as footer.php or footer.incl, or footer.html.
    If that's the case here, you need a local testing server to see them in your parent page.
    Nancy O.

  • On ipad 2 ps touch just keeps crashing it appears from reviews this is a common problem, how does one access a refund

    On ipad 2 ps touch just keeps crashing it appears from reviews this is a common problem, how does one access a refund

    As stated, completely exit pst (don't just leave the app) and then activate airplane mode. Then open PST and change your cloud sync option to "off". Once you deactivate airplane mode, you should be able to open PST again without the crash. Iirc, I had to work at opening PST and accessing my settings very quickly or it would still crash before opening the settings page. Unfortunately, we have to completely forget about cloud sync until the bug is fixed. Save any image files back to the ios camera roll to share with other apps or upload elsewhere.

  • HOW DOES ONE ACCESS / OPEN INSERTED SD CARD CONTAINING MP3s WITH ITUNES?

    Hello,
    How does one access / open an inserted SD card containing MP3s with ITUNES?
    Thanks
    < Edited by Host >

    File > Add Folder {or File} to library.

  • How does sccm access admin shares on workgroup computers???

    Hey guys, how does sccm access admin shares on workgroup computers??? I know that in software distribution component i can add domain account that is used by client to access dp's and stuff. I have some workgroup computers that have client installed
    manually by someone who has access to sccm server with domain account. But that is only used for install but what about later?

    Hi,
    the SCCM Site server will never access the client directly only when you use Client Push and in client push settings you can define local administrator accounts and passwords to try as well when you push out the client.
    If you install the sccm client manually you don't have to worry about access to any shares on workgroup computers.
    Regards,
    Jörgen
    -- My System Center blog ccmexec.com -- Twitter
    @ccmexec

  • How does Internet access work once I leave home?

    Do I need to subscribe to a wireless broadband deal- such as BT's Openzone- in order to access the Internet on my macBook when I'm away from home ... or can I depend on dialling my ISP via a phone socket? How does Internet access work once I leave home?

    BT Openzone looks a lot like T-Mobile wireless here in the States. I've got a T-Mobile account and password. When I go into a location that has TM, I open up my MacBook and look under my AirPort menu icon to select the TM network. Then I enter my account name and password and go.
    Of course TM isn't everywhere, just as BT's service isn't. When I'm in a location that doesn't have it, how I connect depends on what does exist. I always travel with an ethernet cable because many hotels don't have wireless but do have ethernet connections. I've not had to resort to modem service is more than 5 years.

  • How does one access their images in their libraries in Desktop Adobe Photoshop that are connected to their Mobile Adobe Shape?

    So
    I have Adobe Shape on my iphone, and in my Creative Cloud on the web it can access the images ive made. BUT, these images wont show up in my library on Photoshop on my computer and i cant seem to save them from the creative cloud on the web.
    How does one get from A to B?
    Thankyou
    Victoria

    Hi Victoria and welcome to the forum.
    I had to Google Shape but it looks interesting, and dies use the CC Libraries.  I am a big fan of CC Libraries, but have only used them between apps on the same machine.  So it is just a matter of see how they work between different systems
    Illustrator Help | Creative Cloud libraries - collaborate, sync, and share assets
    In my experience, I simply drag an asset onto the Library in one app, and it is there in my other apps.  But I have to make sure I am looking at the same library name on both computers.  Now I have been confused over syncing before, but I suspect that if you open the Application Manager and click on the little Cog icon, and in the Files tab make sure Sync is checked.  Otherwise you might as well read the help files.
    Sync digital assets in Adobe files and apps | Creative Cloud Libraries
    Good luck

  • How does oracle accesses v$ tables or views in mount state

    Hi All,
    I want to know how oracle accesses fixed tables/views while the database is in mount state.
    I did the following:
    1. Started the database in mount state.
    2. Query v$database ,v$datafile--Successful
    3. Queried dba_data_files.---ERROR
    SQL> select * from dba_data_files;
    select * from dba_data_files
    ERROR at line 1:
    ORA-01219: database not open: queries allowed on fixed tables/views only
    As per my understanding goes,all these tables are a part of Data Dictionary which is stored physically on system tablespace.
    Now since the database is mounted ,it cannot access any part of system tablespace's data.Am I right??
    So how does it queries v$ tables and other fixed database tables in mount state???
    Thanks in advance
    Saket Bansal

    the v$(dynamic) view comes from instance
    the dba(static) views comes from dictionary
    but there is only one view can be look while instance is in nomount mode
    and that is
    v$instance ,,,
    BUT ONLY THING I DON KNOW IS WHY WE CAN STILL DESCRIBE THE V$ VIEWS WHILE INSTANCE IS IN NOMOUNT MODE,,,
    ORACLE instance shut down.
    SQL> startup nomount;
    ORACLE instance started.
    Total System Global Area 285212672 bytes
    Fixed Size 1248576 bytes
    Variable Size 75498176 bytes
    Database Buffers 205520896 bytes
    Redo Buffers 2945024 bytes
    SQL> desc v$datafile;
    Name Null? Type
    FILE# NUMBER
    CREATION_CHANGE# NUMBER
    CREATION_TIME DATE
    TS# NUMBER
    RFILE# NUMBER
    STATUS VARCHAR2(7)
    ENABLED VARCHAR2(10)
    CHECKPOINT_CHANGE# NUMBER
    CHECKPOINT_TIME DATE
    UNRECOVERABLE_CHANGE# NUMBER
    UNRECOVERABLE_TIME DATE
    LAST_CHANGE# NUMBER
    LAST_TIME DATE
    OFFLINE_CHANGE# NUMBER
    ONLINE_CHANGE# NUMBER
    ONLINE_TIME DATE
    BYTES NUMBER
    BLOCKS NUMBER
    CREATE_BYTES NUMBER
    BLOCK_SIZE NUMBER
    NAME VARCHAR2(513)
    PLUGGED_IN NUMBER
    BLOCK1_OFFSET NUMBER
    AUX_NAME VARCHAR2(513)
    FIRST_NONLOGGED_SCN NUMBER
    FIRST_NONLOGGED_TIME DATE
    SQL> desc v$tablespace;
    Name Null? Type
    TS# NUMBER
    NAME VARCHAR2(30)
    INCLUDED_IN_DATABASE_BACKUP VARCHAR2(3)
    BIGFILE VARCHAR2(3)
    FLASHBACK_ON VARCHAR2(3)
    ENCRYPT_IN_BACKUP VARCHAR2(3)
    HOW DOES THIS COME FROM ????
    Edited by: jignesh kankrecha on Jul 6, 2009 8:12 AM

  • How to: Transform Activity: Read global/local variable, execute java code

    Could anyone please show me how to do that???

    could you please elaborate your usecase? yes you can read global variable using getVariableData( ) xpath function and pass them as an argument to the processXSLT ( ) xpath function.
    You can read the global or local variables inside java exec using, please refer samples/references/javaexec sample.

  • How does the abstract method do its job?

    //SSLSocketFactory factory =
              (SSLSocketFactory)SSLSocketFactory.getDefault();
    //SSLSocket socket =
              (SSLSocket)factory.createSocket("www.verisign.com", 443);
    The method 'createSocket(String host, int port)' is an abstract method, I'm confused that how this method did created a socket with an empty implementation?
    Can you help?

    //SSLSocketFactory factory =
    (SSLSocketFactory)SSLSocketFactory.getDefault();
    //SSLSocket socket =
    (SSLSocket)factory.createSocket("www.verisign.com", 443);
    The method 'createSocket(String host, int port)' is an abstract method, I'm confused that how this method did created a socket with an empty implementation?
    Can you help?
    The SSLSocketFactory's getDefault() method has an implentation that will return a class of type SSLSocketFactory. Example (this may not be the code but it's close):
    public abstract class SSLSocketFactory ... {
       ... // other methods
       public SSLSocketFactory getDefault(){
          return new SSLSocketFactoryImpl();
       private class SSLSocketFactoryImpl extends SSLSocketFactory {
          // concrete implementation of methods...
          public SSLSocket createSocket(..., ..., ....){
             return new SSLSocketImpl(..., ..., ...);
          private class SSLSocketImpl extends SSLSocket {
             SSLSocketImpl(..., ..., ...){
             // concrete implementation of methods...
    }As you can see here it is not really the SSLSocketFactory and SSLSocket that you are getting. You are getting concrete implementations of this class.
    To prove to you, change your code to this:
    //SSLSocketFactory factory =
    (SSLSocketFactory)SSLSocketFactory.getDefault();
    //SSLSocket socket = (SSLSocket)factory.createSocket("www.verisign.com", 443);
    System.out.prinntln(factory.getClass().getName());
    System.out.prinntln(socket.getClass().getName());This will show you the actual name of the classes.

Maybe you are looking for

  • Download error. Tap to retry and syncing problems!

    I can't sync music to my iphone 4s, i tried so many times to sync music to it after managing and adding music to my itunes library then dragging them to my iphone, but when i go to my Iphone Music app, only "No content" appear inside the app, no tabs

  • IRecruitment records in FND_USER

    We are using the iRecruitment for couple years. Since it creates records in FND_USER table this table grows rapidly. While writing custom code which must join to this table we often have a need to only user "real" users (not irecruitment created) acc

  • How can i text/send multipe photos under 1 text/e-mail?

    does anyone know how to test/e-mail multipe attachments under one text/email?

  • Do N73 Music Edition offer screensaver feature?

    Do N73 Music Edition offer screensaver feature? Pls help me...

  • Mac Solution To Transfering Video???

    Ok, everyone is talking about videroa, but please stop because this is a apple website and alot of us have macs. we need a program that works well. does anyone know of a definite program other than qt pro and imovie. Im trying toast 7. h.236 doesnt w