Personally I would recommend following ways to implement infinite loop in Java but their can be other ways like calling a method recursively , though I never tested that.
Calling a method recursively would not be a good idea for an infinite loop - every recursive call results in adding to the stack, and after a few times through the "loop" there would be a stack overflow.
2 comments:
for(;;);
while(true);
do{}while (true);
Calling a method recursively would not be a good idea for an infinite loop - every recursive call results in adding to the stack, and after a few times through the "loop" there would be a stack overflow.
Post a Comment