2012-03-05 28 views
0

我比較if條件中的字符串並在if條件中打印selectedradbtn的值。在這裏,selectedradbtn是如果條件中打印...但是當我在打印之前,如果條件的值正在打印...如何獲取if條件內的值?

我的代碼:

ArrayList<String> array2; 
static int selectedradbtn; 


selectedradbtn = Previouspage.selectedradiobtn; 
System.out.println("selected radio button outside if"+selectedradbtn); //here value is printing 
if(Integer.toString(selectedradbtn).equals(array2.get(0)) && array2.get(3).equals("1")) 
{ 
    System.out.println("selected radio button in if"+selectedradbtn); //value not printing 
    correct = correct+ 1; 
    System.out.println("correct if"+correct); 
} 

在哪裏,我錯了.. 。請幫我對此... 在此先感謝...

+2

也許你沒有在'if'塊中輸入,因爲條件是'false'? – Luksprog 2012-03-05 10:29:48

+0

只是調試你的代碼是否執行進入if塊或不。 – user370305 2012-03-05 10:36:51

+0

是你的arraylist空?????或者如果在Log或System.out.println – 2012-03-05 10:37:53

回答

0

不知道,但是這是否幫助

selectedradbtn = Previouspage.selectedradiobtn; 
System.out.println("selected radio button outside if"+selectedradbtn); //here value is   printing 
if((Integer.toString(selectedradbtn).equals(array2.get(0)) && (array2.get(3).equals("1"))) 
{ 
    System.out.println("selected radio button in if"+selectedradbtn); //value not printing 
    correct = correct+ 1; 
    System.out.println("correct if"+correct); 
} 
0

添加其他{}並檢查您的條件是否滿足。