The snippet below is one constructor i have for the class TimeFun. The value s is the current (get) seconds value.
i have been experienting with this code, ideally im trying to make a timer count up from 0, but without using a thread. I simply cannot understand why the while always evaluates to true.Code:TimeFun(int s) { int timestart = s; Calendar Tim = new GregorianCalendar(); do { System.out.print("A second"); } while (Tim.get(Calendar.SECOND) == timestart); System.out.print("A second has expired"); }
Im not looking for an alternative way to solve the problem, just an explanation of why the output is an infinite stream of System.out.print
Thanks


Reply With Quote


Bookmarks