View Full Version : sustring problem

10-15-2005, 02:07 AM
hi, I'm a first-level java learner, so my questions might seem really basic. but I don't really have a clue as to what I'm doing wrong. Can you guys please help out?

I'm supposed to write a program that ask the user to input their email address. and The first letter and the last letter cannot be '@'. Moreover, '@' is supposed to be included somewhere in the middle of the input.
I'm asking the user to input the data in PersonDB class. and I'm trying to write the validator for the email in another class called the Validator.

so in the PersonDB class, I have:

//String email_String = Validator.getString(sc, "Enter Email Address: ");
System.out.println("Enter Email Address: ");
String email = sc.next();
int strLength = email.length();
System.out.println("" + strLength);
Validator.validateEmail(email, strLength);

and in the Validator class, I have:

public boolean validateEmail(String emailValid, int strLength)
isvalid = false;

while ((emailValid.substring(0).equals('@'))
|| (emailValid[emailValid - 1].equals('@')))
System.out.println("ERROR! you cannot enter @ at the beginning or the end of your email address.\n");

if (int index = 1, index < strLength-1, index++)
if (emailValid[index].equals("@"))
return true;
if (index == strLength-2)
return false;

return isvalid;

Please help me out. I really don't know what else to do.

Philip M
10-15-2005, 09:15 AM
You are in the wrong forum. Perhaps one thing to learn is that Java is not at all the same as JavaScript, in spite of the confusingly similar names.