Maybe not the best practice, but certainly straightforward: I would write a recursive method that counts a value that repeats until java.lang.StackOverflowError and looks at the counter.
public class Test { static void recur(AtomicInteger start) { start.incrementAndGet(); recur(start); } public static void main(String[] args) throws ParseException { AtomicInteger start=new AtomicInteger(0); try { recur(start); } catch (java.lang.StackOverflowError e) { } System.out.println(start); } }
fiffy
source share