static variable lose its value

Posted by user542719 on Stack Overflow See other posts from Stack Overflow or by user542719
Published on 2011-01-15T08:24:34Z Indexed on 2011/01/15 8:53 UTC
Read the original article Hit count: 238

Filed under:
|

I have helper class with this static variable that is used for passing data between two classes.

public class Helper{
    public static  String paramDriveMod;//this is the static variable in first calss
}

this variable is used in following second class mathod

public void USB_HandleMessage(char []USB_RXBuffer){

 int type=USB_RXBuffer[2];
 MESSAGES ms=MESSAGES.values()[type];


 switch(ms)

   {
    case READ_PARAMETER_VALUE:  // read parameter values

                switch(prm){
                    case PARAMETER_DRIVE_MODE:  // paramet drive mode


                       Helper.paramDriveMod =(Integer.toString(((USB_RXBuffer[4]<< 8)&0xff00)));
                       System.out.println(Helper.paramDriveMod+"drive mode is selectd ");//here it shows the value that I need.

..........}}//let say end switch and method and the following is an third class method use the above class method

public void buttonSwitch(int value) throws InterruptedException{ boolean bool=true; int c=0; int delay=(int) Math.random(); while(bool){ int param=3; PARAMETERS prm=PARAMETERS.values()[param];

switch(value){ case 0: value=1;

            while(c<5){
            Thread.sleep(delay);                
            protocol.onSending(3,prm.PARAMETER_DRIVE_MODE.ordinal(),dataToRead,dataToRead.length);//read drive mode
            System.out.println(Helper.paramDriveMod+"  drive mode is ..........in wile loop");//here it shows null value

}}//let say end switch and method

what is the reason that this variable lose its value?

© Stack Overflow or respective owner

Related posts about java

Related posts about static