I am new to Java programming. Can anyone tell what is the difference between global and local variable in Java?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question is a little confused since you refer to static/global in the title, and global/local in your question.
staticvariables are tied to a class, and you will have one instance per class.classes can have member variables, and you will have one instance per instance of that class.
Note that this is complicated further if you have multiple classloaders. In this scenario you can have multiple class definitions loaded, and consequently, possible multiple static variables.