Oracle上的教程贴,新手被鄙视了,大家来看看
这是网址 http://docs.oracle.com/javase/tutorial/i18n/intro/after.html
public class I18NSample {
static public void main(String[] args) {
String language;
String country;
if (args.length != 2) {
language = new String("en");
country = new String("US");
} else {
language = new String(args[0]);
country = new String(args[1]);
}
Locale currentLocale;
ResourceBundle messages;
currentLocale = new Locale(language, country);
messages = ResourceBundle.getBundle("MessagesBundle", currentLocale);
System.out.println(messages.getString("greetings"));
System.out.println(messages.getString("inquiry"));
System.out.println(messages.getString("farewell"));
}
}
不明白arg[0],arg[1],这个字符数组里有值吗,怎么传进来了?
------解决方案--------------------楼主没有用命令行来启动过java程序么?
java I18NSample en US
------解决方案--------------------如果是在Eclipse里面运行的话,可以在run configurations里面的Arguments中添加你要传的参数。多个参数以空格隔开