JAva(簡単なメールボックスの判断)ユーザーはコマンドラインから文字列を入力し、合法的なemailアドレスかどうかを判断するように要求し、合法的であればsinaのメールアドレスかどうかを判断してください.
2561 ワード
package com.tjetc.daomain;
import java.util.Scanner;
import java.util.Scanner;
public class Work05 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print(" :");
String str = input.nextLine();
int count=0;// @
int count2=0;// .
int x=0;// @
int y=0;// .
for(int j = 0;j1;j++){
String str1 =str.substring(j,j+1);
if(str1.equals("@")){
count++;
x=j;
}
if(str1.equals(".")){
count2++;
y=j;
}
//continue;
}
if(count==1 && count2==1 && x1) && x!=0 && y!=str.length()-1 ){
str.endsWith("@sina.com");
System.out.println(" ");
}else{
System.out.println(" ");
}
}
}