我需要编写一个程序,让用户输入一次字符串日期(例如 10/21),然后将该字符串转换为整数。我想在解析之前需要拆分?
import java.util.Scanner;
public class ConvertDates {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Please input a date (mm/dd): ");
String k = input.next();
k = String.split("/");
int mm = Integer.parseInt(k);
int dd = Integer.parseInt(k);