Skip to main content
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Email validation aside...Email validation aside...

Switching between GUI input and console output

You take your input via a JOptionPane, but the output of your validation is displayed via System.out. It will be much better UX-wise to show the result as another dialog box too.

Braces

Please use braces, it's not that hard. One extra line here or there and your conditions/loops will look even messier to clean up.

Boolean assignment and evaluation

if(dot1==0)
    dot=false;
else dot=true;

This can be rewritten as dot = dot1 != 0.

while(at==false||domain==false||dot==false||tld==false)

This can be rewritten as while (!(at && domain && dot && tld)).

And speaking about variable names...

Variable names

It's not easy to decipher what do at1, at2, dot1 etc. mean. It's recommended to use more descriptive names here, e.g. hasTLD.

Email validation aside...

Switching between GUI input and console output

You take your input via a JOptionPane, but the output of your validation is displayed via System.out. It will be much better UX-wise to show the result as another dialog box too.

Braces

Please use braces, it's not that hard. One extra line here or there and your conditions/loops will look even messier to clean up.

Boolean assignment and evaluation

if(dot1==0)
    dot=false;
else dot=true;

This can be rewritten as dot = dot1 != 0.

while(at==false||domain==false||dot==false||tld==false)

This can be rewritten as while (!(at && domain && dot && tld)).

And speaking about variable names...

Variable names

It's not easy to decipher what do at1, at2, dot1 etc. mean. It's recommended to use more descriptive names here, e.g. hasTLD.

Email validation aside...

Switching between GUI input and console output

You take your input via a JOptionPane, but the output of your validation is displayed via System.out. It will be much better UX-wise to show the result as another dialog box too.

Braces

Please use braces, it's not that hard. One extra line here or there and your conditions/loops will look even messier to clean up.

Boolean assignment and evaluation

if(dot1==0)
    dot=false;
else dot=true;

This can be rewritten as dot = dot1 != 0.

while(at==false||domain==false||dot==false||tld==false)

This can be rewritten as while (!(at && domain && dot && tld)).

And speaking about variable names...

Variable names

It's not easy to decipher what do at1, at2, dot1 etc. mean. It's recommended to use more descriptive names here, e.g. hasTLD.

Source Link
h.j.k.
  • 19.2k
  • 3
  • 36
  • 93

Email validation aside...

Switching between GUI input and console output

You take your input via a JOptionPane, but the output of your validation is displayed via System.out. It will be much better UX-wise to show the result as another dialog box too.

Braces

Please use braces, it's not that hard. One extra line here or there and your conditions/loops will look even messier to clean up.

Boolean assignment and evaluation

if(dot1==0)
    dot=false;
else dot=true;

This can be rewritten as dot = dot1 != 0.

while(at==false||domain==false||dot==false||tld==false)

This can be rewritten as while (!(at && domain && dot && tld)).

And speaking about variable names...

Variable names

It's not easy to decipher what do at1, at2, dot1 etc. mean. It's recommended to use more descriptive names here, e.g. hasTLD.