Hackerrank 30 days of code Java Solution: Day 16: Exceptions – String to Integer

The next problem is based on very important concept called Exceptions. Exceptions are very important part of developer life. It teaches you the hard reality of programming. Exceptions are the unwanted or unexpected code behaviour. Therefore Exception handling is very important and highly recommended. Exception handling main objective is to end a program or a flow “Gracefully”.

There are two types of exceptions checked and unchecked. We would give you detail story on exception and exception handling very soon in the blog.

Currently, for the problem statement solution lies below
Task

Read a string, , and print its integer value; if  cannot be converted to an integer, print Bad String.

Sample Input

Sample Output

Sample Input

Sample Output

So here  lies your Solution .

Thanks for the visit checkout the day 17 tutorial as well.. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *