Here is some really simple code to achieve this:
String ourString = "[email protected]"; if(/* Check if our string is null: */ ourString != null && /* Check if our string is empty: */ !ourString.isEmpty() && /* Check if our string contains "@": */ ourString.contains("@")) { System.out.println("String Fits the Requirements"); } else { System.out.println("String Does Not Fit the Requirements"); }
For future reference, this is extremely broad for Stack Overflow, and you should try checking the javadoc before you make a post asking for the answer. For example, here is the javadoc for the String class: https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
Javadocs provided by Oracle detail every method and attribute for all of the classes included in the standard java library. Here is a link to the javadoc homepage for Java 7. https://docs.oracle.com/javase/7/docs/api/overview-summary.html
str != null && str.contains("@")str != null && str.contains("@")