How to write the code of main method in short


Discuss the below:

Q: How do I rewrite this main method so is uses as few lines of code as possible, preferably a single line?

public static void main (String [] args)
{
String s;
boolean b;
JOptionPane jop;

jop = new JOptionPane();

s = jop.showInputDialog("Enter your email address");
b = s.matches(".*@.*..*");
if (b)
{
System.out.println("Address Appears Valid");
}
else
{
System.out.println("Address is Invalid");
}
}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: How to write the code of main method in short
Reference No:- TGS01934121

Now Priced at $20 (50% Discount)

Recommended (99%)

Rated (4.3/5)