Intro to Tutorial Challenges

  • + 2 comments

    The reduction in code here comes with a risk. If the input does not contain sufficient data(here int) , the code will fail as nextInt() will throw an Exception. Although input conditions are met in the test cases, in general,its always advised to check hasNextXXX() method before calling respective nextXXX() method to avoid any runtime exceptions or errors. Hope it meakes sense.