我需要一個解析輸入字符串(電子郵件地址)並以規範化格式打印的程序。它應該有3個由','分隔的部分,如下所示:Int,Int,String前兩個整數部分表示程序應該提取的子字符串的第一個和最後一個字符的索引。 例如,假設我輸入以下內容作爲輸入:0,6,alex.da @ yahoo.com =>輸出應該變成=> alex.da 有誰知道如何做到這一點?如何解析輸入字符串並以規範化形式打印? (Java)
import java.util.Scanner;
public class Labs02 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.println("enter your Email:");
String response = stdIn.nextLine();
String first=response.substring(0,1);
int second=response.indexOf(response.charAt(2));
System.out.println(response.substring(response.indexOf(response.substring(0, 1))+4));
} //This is where I get stuck!
刪除了JavaScript代碼。 –