Avatar of Amit
Amit
Flag for United States of America asked on

Issues with the scope of a variable

Hi,

In the attached file I have the following function which is a void. But I want to store the max_session_state in such a way that in can be accessed globally anywhere in the code.

Or can can be a protected class member of a new class say SessionTask class but I should be able to access this from an accessor method anywhere in the code

I am hitting a dead end here. Any help ?  Also can someone point me to a really good tutorial on scope of a variable and how to handle multiple scenarios with it


thanks
-anshu



public void characters(char ch[], int start, int length) throws SAXException {
 
            
            if (max_state) {
                  
                              
                  //System.out.println("Max Session State : " + new String(ch, start, length));
                  
                  String max_session_state=new String(ch, start, length);
                  
                  System.out.println("Max Session State : " + max_session_state );
                  
                  max_state = false;
            }
java-scop.txt
Java

Avatar of undefined
Last Comment
Chris Ashcraft

8/22/2022 - Mon
SOLUTION
AllThingsJava

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Gurvinder Pal Singh

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
for_yan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Chris Ashcraft

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61