This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Tim Moores wrote:Your manager specifically tells you which classes you can and can not use? Seems like a micro-managing PHB who should get out of your way.
To me it sounds more like a student falsely claiming that homework is a work assignment. No real manager--even in the worst hellhole outsourcing shop ever--would ever forbid you from using the core API. And if he does (which he never will), you should run as fast as you can. Cleaning toilets in a bus station in the slums of hell would be a better job than that.
govind soni
Greenhorn
Joined: Dec 07, 2010
Posts: 11
posted
0
:-D :-D
govind soni
Greenhorn
Joined: Dec 07, 2010
Posts: 11
posted
0
Check this code I tried myself but this is not showing correct email validation..... try by yourside and tell me the updates.
import java.lang.*;
import java.io.*;
public class EmailV{
public static void main(String[] args) throws IOException{
System.out.println("Email Validation");
BufferedReader bf =
new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter mailid:");
String str1 = bf.readLine();
String myString="str1";
String at="@";
String dot=".";
int lstr = myString.length();
int lat = myString.indexOf("at");
int ldot = myString.indexOf("dot");
{
if (myString.indexOf(at)==-1 || myString.indexOf(at)==0 ||
myString.indexOf(at)==lstr)
System.out.println("Invalid E-mail ID");
else
if (myString.indexOf(dot)==-1 || myString.indexOf(dot)==0 ||
myString.indexOf(dot)==lstr)
System.out.println("Invalid E-mail ID");
else
if (myString.indexOf(at,(lat+1))!=-1)
System.out.println("Invalid E-mail ID");
else
if (myString.substring(lat-1,lat)==dot ||
myString.substring(lat+1,lat+2)==dot)
System.out.println("Invalid E-mail ID");
else
if (myString.indexOf(dot,(lat+2))==-1)
System.out.println("Invalid E-mail ID");
else
if (myString.indexOf(" ")!=-1)
System.out.println("Invalid E-mail ID");
govind soni wrote:Check this code I tried myself but this is not showing correct email validation..... try by yourside and tell me the updates.
My first update would be to recommend that you add some debugging messages -- this will enable you to figure out what is going on, and hence, be able to fix it. This way, when you come back here, you can ask specific questions, and with specific details.
My second recommendation is to use the equals() method to compare strings. The "==" operator is used to compare references, which is not what you want.
Henry Wong wrote:This way, when you come back here, you can ask specific questions, and with specific details.
And when you do come back and ask specific questions with specific details, make sure you're clear about what your actual requirements are. "Valid email address" can have many different interpretations (Read this page for some examples.) and in the absence of specific requirements for your particular case, the only reasonable default would be RFC 2822, and I doubt you actually have to implement conformance to that.