大家好!
我想定义一个变量,在一个class的多个方法之间公用,但是下面的代码在运行的时候有错误,请大家帮我看看,谢谢!
public class TestHtml
{
public String mystr1 = ""; public void wdDoInit()
{
mystr1 = "0123";
}
public void onActionExportIE(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
String mystr2 = mystr1 + "b";
}}
我想定义一个变量,在一个class的多个方法之间公用,但是下面的代码在运行的时候有错误,请大家帮我看看,谢谢!
public class TestHtml
{
public String mystr1 = ""; public void wdDoInit()
{
mystr1 = "0123";
}
public void onActionExportIE(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
String mystr2 = mystr1 + "b";
}}
public static void wdDoInit()
{
mystr1 = "0123";
}public static void onActionExportIE(.....)
{
String mystr2 = mystr1 + "b";
}
public static void wdDoInit()
{
mystr1 = "0123";
}public static void onActionExportIE(.....)
{
String mystr2 = mystr1 + "b";
}
{
public static String mystr1 = ""; //要在静态区域使用静态变量
public void wdDoInit()
{
mystr1 = "0123";
}
public void onActionExportIE(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
String mystr2 = mystr1 + "b"; } }
刚才大家有的说代码有问题, 有的说没有问题也都晕了!
我使用的软件是webdynpro,它的语言是java,
但是它在定义变量的时候有严格的要求(位置上)给前后加个标签就好了,
如下:public class TestHtml
{
public void wdDoInit()
{
mystr1 = "0123";
}
public void onActionExportIE(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
String mystr2 = mystr1 + "b";
} //@@begin others
public String mystr1 = "";
//@@end
} //@@begin others
public String mystr1 = "";
//@@end希望大家能知道这个原因,谢谢!稍后结贴!
public String mystr1 = "";
//@@end不要了