ArrayList
ArrayList
add("A");
add("B");
add("C");
}}
link
Map
Map
{
put(".jpg", "image/jpeg");
put(".jpeg", "image/jpeg");
}
};
Object | Thread |
---|---|
notify notifyAll wait | sleep yield |
properties files for 3 resource bundles:
LabelsBundle.properties
LabelsBundle_de.properties
LabelsBundle_fr.properties
resource bundle sample content:
# This is the LabelsBundle_de.properties file
s1 = Computer
s2 = Platte
s3 = Monitor
s4 = Tastatur
use of resource bundle sample:
Locale[] supportedLocales = {
Locale.FRENCH,
Locale.GERMAN,
Locale.ENGLISH
};
for (int i = 0; i < supportedLocales.length; i ++) {
ResourceBundle labels =
ResourceBundle.getBundle("LabelsBundle",currentLocale);
String value = labels.getString(key);
Enumeration bundleKeys = labels.getKeys();
while (bundleKeys.hasMoreElements()) {
String key = (String)bundleKeys.nextElement();
String value = labels.getString(key);
}
}
3 resource bundles:
StatsBundle_en_CA.class
StatsBundle_fr_FR.class
StatsBundle_ja_JP.class
resource bundle sample:
import java.util.*;
public class StatsBundle_ja_JP extends ListResourceBundle {
public Object[][] getContents() {
return contents;
}
private Object[][] contents = {
{ "GDP", new Integer(21300) },
{ "Population", new Integer(125449703) },
{ "Literacy", new Double(0.99) },
};
}
use of resource bundle sample:
Locale[] supportedLocales = {
new Locale("en","CA"),
new Locale("ja","JP"),
new Locale("fr","FR")
};
for (int i = 0; i < supportedLocales.length; i ++) {
ResourceBundle stats =
ResourceBundle.getBundle("StatsBundle",currentLocale);
Integer gdp = (Integer)stats.getObject("GDP");
}
Throwable
'-> Error
'-> AnnotationFormatError
'-> AssertionError
'-> IOError
'-> ThreadDeath
'-> ...
'-> Exception
'-> RuntimeException
'-> ArithmeticException
'-> ArrayStoreException
'-> ClassCastException
'-> ConcurrentModificationException
'-> IndexOutOfBoundsException
'-> NullPointerException
'-> ...
'-> ClassNotFoundException
'-> CloneNotSupportedException
'-> InterruptedException
'-> IOException
'-> NoSuchMethodException
'-> ...
Synchronized | Unsynchronized |
---|---|
StringBuffer | StringBuilder |
Vector | ArrayList |
Hashtable | HashMap |
CLASSPATH
variable, use these commands in Windows and Unix (Bourne shell): To delete the current contents of theIn Windows: C:\> set CLASSPATH
In Unix: % echo $CLASSPATH
CLASSPATH
variable, use these commands: To set theIn Windows: C:\> set CLASSPATH=
In Unix: % unset CLASSPATH; export CLASSPATH
CLASSPATH
variable, use these commands (for example): In Windows: C:\> set CLASSPATH=C:\users\george\java\classes
In Unix: % CLASSPATH=/home/george/java/classes; export CLASSPATH
public class MyLibrary {
public static final String VERSION; // blank final
static {
VERSION = "1.0"; // initialized separately
}
}