Search code examples
javaemailvalidationemail-address

validate that an email address contains "@" and "."


i need to validate that an inserted email address contains "@" and "." without a regular expression. Can somebody to give me "java code" and "structure chart" examples please?


Solution

  • I suspect you're after something like:

    if (!address.contains("@") || !address.contains("."))
    {
        // Handle bad address
    }
    

    EDIT: This is far from a complete validation, of course. It's barely even the start of validation - but hopefully this will get you going with the particular case you wanted to handle.