Validating input in java

If you’ve studied CS, you’ve undoubtedly taken a course about compilers or something similar; in these classes, the concept of Finite Automaton (also known as Finite State Machine) is taught.This is a way of formalizing the grammar rules of languages. So how can this forgotten concept be helpful to us, high-level programmers, who don’t need to worry about building a new compiler?Validating input received from the user to maintain data integrity is an important part of application logic.Validation of data can take place at different layers in even the simplest of applications, as shown in Developing a Simple Facelets Application.Copyright © 1993, 2016, Oracle and/or its affiliates. Input validation is performed to ensure only properly formed data is entering the workflow in an information system, preventing malformed data from persisting in the database and triggering malfunction of various downstream components.

Once we have the both numbers validated, we add them up.

The tag) for numerical data at the presentation layer and for a valid range of numbers at the business layer.

Java Beans Validation (Bean Validation) is a new validation model available as part of Java EE 6 platform.

To do so, we first have to verify that the user has inserted two numbers and not any other character, which can´t be add up.

If the user inserts both numbers correctly there will be no problem.