Results 1 to 4 of 4
  1. #1
    sreekanthgude is offline Member
    Join Date
    Jan 2014
    Rep Power

    Post Local variables in java

    you can also refer this link Local variables in java? « Programmers99

    Local variables in java?
    ----> To meet temporary requirements of the programmers some times

    we have to create variables inside method or bock or constructor such type of variables are

    called as Local Variables.

    ----> Local variables also known as stack variables or automatic variables or temporary variables

    ----> Local variables will be stored inside Stack.

    -----> The local variables will be created while executing the block

    in which we declared it and destroyed once the block completed. Hence the scope

    of local variables is exactly same as the block in which we declared it.



    class A{

    public static void main(String args[]){

    int i=0; // Local variable

    String s="javatask"; //Local variable




    ----> For JVM wont provide any default values . We should do initialization explicitly

    before using the variable.Other wise you will get Variable might not have been initialized error.

    ----> The only applicable modifier for the local variable is "final" if we are using any

    other modifier we will get compile time error..

    Hi friends if you have any doubts regarding this topic please put comment below

    i will try clarify those..

  2. #2
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Rep Power

    Default Re: Local variables in java


  3. #3
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Local variables in java

    This person is spamming the site with his/her thoughts on various aspects of Java.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Local variables in java

    Quote Originally Posted by jim829 View Post
    This person is spamming the site with his/her thoughts on various aspects of Java.
    Yep, I think so too; I'm closing all his/her threads.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Variables in MainMethod(). Local or Instance.
    By Flamey in forum New To Java
    Replies: 3
    Last Post: 06-10-2011, 06:46 AM
  2. Are Local variables thread safe ?
    By samson in forum Threads and Synchronization
    Replies: 6
    Last Post: 12-21-2010, 03:34 PM
  3. Replies: 1
    Last Post: 12-27-2009, 03:13 AM
  4. Local variables unavailable
    By Onra in forum New To Java
    Replies: 9
    Last Post: 11-25-2009, 10:39 PM
  5. Re-docking the Local Variables window
    By ScottVal in forum NetBeans
    Replies: 0
    Last Post: 01-20-2009, 08:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts