Android 如何从一个方法中获取字符串值?
Hi have a class包含一个Android 如何从一个方法中获取字符串值?,android,string,function,Android,String,Function,Hi have a class包含一个method(),在该方法中有一个字符串 public method() { String check = Question.check; } 现在我需要在与static相同的类中获取这个String值,以便在类中进一步使用String 如何获取方法外部的字符串作为静态字符串 请告诉我如何获取和使用它。在类构造函数中,像这样获取字符串值 String result=method(); 关闭构造函数后,请执行以下操作: public
method()
,在该方法中有一个字符串
public method() {
String check = Question.check;
}
现在我需要在与static相同的类中获取这个String
值,以便在类中进一步使用String
如何获取方法外部的字符串作为静态字符串
请告诉我如何获取和使用它。在类构造函数中,像这样获取字符串值
String result=method();
关闭构造函数后,请执行以下操作:
public String method() {
String check = Question.check;
return check;
}
你可以按如下方式打电话
static String returnedData=method();
先读Java,再读Android。强烈建议使用静态字符串创建一个类,并在需要时使用setter和getter函数来检索该值。
static String returnedData=method();