好的......所以我已经做了很多试验和错误......我似乎无法将我的 usFormat 方法调用到我的 main 中,我想我已经把整个事情搞砸了哈哈......任何帮助会好的。只是...请在初学者级别。
class Date {
String date;
String day;
String month;
String year;
StringTokenizer st;
Scanner sc = new Scanner (System.in);
//instance vars go here
public Date (String date){
while (sc.hasNextLine()) {
st = new StringTokenizer (sc.nextLine());
this.month = st.nextToken();
this.day = st.nextToken();
this.year = st.nextToken();
}
} //end constructor
public String usFormat () {
return month + " " + day + "," + year;
} //end usFormat
public String euFormat () {
return null;
} //end euFormat
public static void main (String[] args){
Date usFormat = new Date (date);
}
}