![](/img/trans.png)
[英]Java - while(true) loop not checking, if condition is true, if the else statement is missing
[英]Eclipse Java Debugger make if statement condition be true
我只想在調試時使if語句變為true。
例:
if(giveMyNumber() == 3){
System.out.println("Is number 3");
}
public int giveMyNumber(){
return 1;
}
所以我想在if語句中停止調試器並模擬為(giveMyNumber()== 3)為true ,以便進入if並打印“ Is number 3”
您可以使用稱為“ 強制返回”的Eclipse功能來返回值3
:
強制從非無效方法中盡早返回需要對表達式進行求值。 例如,如果某個方法要返回false,則可以通過在Display View中選擇一個表達式並調用Force Return來返回true值。 在下面的示例中,
elementCount
不等於零,並且將返回false(請參閱調試懸停,其中顯示elementCount
的值)。在Display View中 ,我們可以輸入要返回的值,選擇它,然后使用Force Return命令強制
isEmpty()
方法返回該值(在下面的示例中,我們將強制isEmpty()
返回該值true
)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.