I have the following method that returns void and I need to use it in another method that also returns void.
Can I do the following?
public void doSomething(){}
public void myMethod()
{
return doSomething();
}
Thanks for all your comments, but let me be more specific
I only doSomething
if something happens, otherwise I do other things
public void doSomething(){}
public void myMethod()
{
for(...)
if(somethingHappens)
{
doSomething();
return;
}
doOtherStuff();
}
Instead of the code above, can I just write return doSomething();
inside the if statement?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…