Explore BrainMass

Explore BrainMass

    Creating a Java One Line Code

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    I have the following code:

    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");
    System.out.println("Address is Invalid");

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

    © BrainMass Inc. brainmass.com October 10, 2019, 7:13 am ad1c9bdddf

    Solution Preview

    public static void main(String[] args) ...

    Solution Summary

    This solution provides the coding which is required for the computer science question being asked. The solution illustrates how code can be re-written to fit into one line.