Determine if a Java file and mailbox format is legitimate

Source: Internet
Author: User

Import Java.util.Scanner;
public class Stringtest {
public static void Main (string[] args) {
int back = 1;
Scanner input =new Scanner (system.in);
do{//Set the loop method until the input is correct
System.out.print ("Java file name:");
String str1 =input.next ();
System.out.print ("Please enter your e-mail:");
String str2= Input.next ();
int m = str2.indexof (' @ '); Check if there is an @ character and use M to receive the index @ appears

int n = str2.indexof ('. '); Check if there is a '. ' Characters, which are received by N. The index that appears

String STR3 = str1.substring (Str1.indexof (".")              +1); Returns the. Trailing substring, +1 is to not include the character '. '
if (!str3.equals ("Java")) {
SYSTEM.OUT.PRINTLN ("Java file name is illegal! ");
}
else{
SYSTEM.OUT.PRINTLN ("Java filename is legal! ");
}
if (! ( M! = -1&& N! = -1&& m <n)) {//if M and N have one for-1, that must be illegal, m and N if valid, the position of M must be smaller than n
System.out.println ("The mailbox name is not legal! ");
}else{
SYSTEM.OUT.PRINTLN ("Legal mailbox name! "); break;
}
}while (back!=3);
}
}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Determine if a Java file and mailbox format is legitimate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.