Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从一个方法中获取字符串值?_Android_String_Function - Fatal编程技术网

Android 如何从一个方法中获取字符串值?

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

Hi have a class包含一个
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();