Reputation: 65
Let's say I have two methods in a method
void hello(){
method1();
method2();
}
Does method2 start only after complete execution of method1 all the time?
Upvotes: 0
Views: 58
Reputation: 719326
Yes. It is guaranteed. The body of a method is a block, and the JLS 14.2 states:
A block is executed by executing each of the local variable declaration statements and other statements in order from first to last (left to right).
Upvotes: 1
Reputation: 4323
yes, that's the definition of the language. If there is no threading involved, one method needs to return before the next one is invoked.
Upvotes: 2