<分区>
我需要从一个方法中存在,我如何在 Java 中做到这一点?
void print(){
try{
coding...
//I need to exist from the print method here.
}catch(){}
}
<分区>
我需要从一个方法中存在,我如何在 Java 中做到这一点?
void print(){
try{
coding...
//I need to exist from the print method here.
}catch(){}
}
最佳答案
使用没有返回值的return
语句:
void print(){
try{
coding...
return;
}catch(){}
}
关于java - 如何打破java中的void方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31131003/