Documente Academic
Documente Profesional
Documente Cultură
n
Palindrome Solutions
n Palindrome
NumberFormat NumberFormat
• In the previous example we used the default • We can find out what locales NumberFormat
locale for formatting the percentages supports by calling the static
• Can also specify a locale getAvailableLocales method
NumberFormat pf = – Returns an array of java.util.Locale objects
NumberFormat.getPercentInstance(Locale.GERMAN); • Locale encapsulates information about a
region—language and country
Num letters: 1314 Num words: 262 Num lines: 37
a: 7,5% • Construct with ISO standard two or three character country
b: 1,3% and language codes
c: 3,8% • Has some static constants for various countries and
d: 2,9% languages
e: 9,9%
. . .
Department of Computer Science 9 Department of Computer Science 10
java.lang.Runtime
Java.lang.System • Runtime allows a Java application to interact with
environment in which the application is running
• System.arraycopy • Can’t construct a Runtime object
– Obtain a Runtime object by calling the static method
– Takes a source array, source position, getRuntime()
destination array, destination position and
length • Some methods:
– int availableProcessors() — # processors
– Throws available to the virtual machine
• IndexOutOfBoundsException if accessing outside of – long freeMemory() — amount of free memory
either source or destination array’s bounds available to the virtual machine
• ArrayStoreException if there is a type mismatch – long maxMemory() — maximum amount of memory
between source and distination arrays that the vitual machine will attempt to use
• NullPointerException if either array is null
Department of Computer Science 17 Department of Computer Science 18