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