NEWS: Total Picture Views: 155282 | Total Article Views: 165601 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. PickUpThings with Becker Robot | 3. How to read a JSON and work with it | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

Exception handling Java


In this example I be showing you how to handle exception in Java


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int x,total;
         total = 10;

        Scanner input = new Scanner(;
                System.out.print("Enter the result of 5 + 5: ");
                //If the user enter something other then integer it will go in the catch exception.
                x = input.nextInt();
            }while(x != total);
        }catch (Exception e){


Attachments: None

Tags: Exception Exception handling

Total Views: 849

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 09/04/14 and updated on 09/05/14


Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.