Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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
Java 返回语句未将值发送到显示_Java_Android - Fatal编程技术网

Java 返回语句未将值发送到显示

Java 返回语句未将值发送到显示,java,android,Java,Android,当get语句之前的所有值(即集合、变量等)都在工作时,我的return语句不工作,如果强制为某个值,则显示工作 if (Pasta.isChecked() && Pork.isChecked() && Tomato.isChecked() && Carrots.isChecked() && TomatoPaste.isChecked()) { // RecipeCodes recip

当get语句之前的所有值(即集合、变量等)都在工作时,我的return语句不工作,如果强制为某个值,则显示工作

  if (Pasta.isChecked() && Pork.isChecked() && Tomato.isChecked() && Carrots.isChecked() && TomatoPaste.isChecked()) {
                       // RecipeCodes recipe1 = new RecipeCodes();
                        //recipe1.setRecipeCode(1);
                        setRecipeCode(1);
                        getRecipecode();
                        //Recipecode = 1;
                        Log.i("INTERNAL CHECK", "RCODE ~" + Recipecode);
                        break;

 public void setRecipeCode(int C) {
    Recipecode = C;
    Log.i("SETRECIPECODETEST", "RECIPE CODE ~ " + Recipecode);
}


public int getRecipecode(){
   return Recipecode;
}
下面是我基于“RecipeCode”变量显示的类的代码

(我已经做了大量的编辑和注释,所以如果有小的语法错误,我的错就不好了)。

这是有效的:

class Recipe {
    private int recipecode;

    public void setRecipeCode(int c) {
        recipecode = c;
    }

    public int getRecipecode() {
        return recipecode;
    }



    public static void main(String[] args)
    {
        Recipe temp = new Recipe();
        temp.setRecipeCode(1);
        System.out.println(temp.getRecipecode());
    }
}

您能通过添加完整的代码详细解释一下哪个返回语句不起作用,在什么情况下?您想要的结果是什么?
class Recipe {
    private int recipecode;

    public void setRecipeCode(int c) {
        recipecode = c;
    }

    public int getRecipecode() {
        return recipecode;
    }



    public static void main(String[] args)
    {
        Recipe temp = new Recipe();
        temp.setRecipeCode(1);
        System.out.println(temp.getRecipecode());
    }
}