Программирование на JAVA
Меню :
Стартовая
Основы программирования
Программирование на JAVA
Программирование на C++
Программирование на Pascal
Задачи по программированию
public String getBehavior(){ return "English behavior";
}
public String getCapital(){ return "London";
}
}
public class RussianBehavior implements Behavior { public RussianBehavior() { }
public String getBehavior(){
return "Русский вариант поведения";
}
public String getCapital(){ return "Москва";
public class MyResourceBundle_ru_RU extends ResourceBundle { Hashtable bundle = null; public MyResourceBundle_ru_RU() { bundle = new Hashtable();
bundle.put("Bundle description","Набор ресурсов для
русской локали"); bundle.putf'Behavior",new RussianBehavior());
}
public Enumeration getKeys() { return bundle.keys();
}
protected Object handleGetObject(String key) throws java.util.MissingResourceException { return bundle.getf'key");
}
public class MyResourceBundle_en_EN { Hashtable bundle = null; public MyResourceBundle_en_EN() { bundle = new HashtableO;
bundle.putf'Bundle descnption'V'English resource set"); bundle.putf'Behavior",new EnglishBehavior());
}
public Enumeration getKeys() { return bundle.keys();
}
protected Object handleGetObject(String key) throws java.util.MissingResourceException { return bundle.getf'key");
}
public class MyResourceBundle extends ResourceBundle { Hashtable bundle = null; public MyResourceBundleO { bundle = new Hashtable();
bundle.putf'Bundle description","Default resource bundle") bundle.putf'Behavior",new EnglishBehaviorO);
}
public Enumeration getKeys() { return bundle.keys();
}
protected Object handleGetObject(String key) throws java.util.MissingResourceException { return bundle.get(key);
}
}
public class Using { public Using() { }
public static void main(String[] args) { Using u - new Using(); ResourceBundle rb =
ResourceBundle.getBundle("lecture.MyResourceBundle", Locale.getDefaultO);
System.out.println((String)rb.getObject("Bundle description")); Behavior be = (Behavior)rb.getObject("Behavior"); System.out.println(be.getBehavior()); System.out.println(be.getCapital());
rb = ResourceBundle.getBundle("lecture.MyResourceBundle", new Locale("en","EN"));