java 2 3
fdsa
fdsa
Set of flashcards Details
Flashcards | 496 |
---|---|
Language | Deutsch |
Category | Computer Science |
Level | Other |
Created / Updated | 06.12.2020 / 24.01.2021 |
Weblink |
https://card2brain.ch/box/20201206_java_2_3
|
Embed |
<iframe src="https://card2brain.ch/box/20201206_java_2_3/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>
|
How to set the default locale?
Locale.setDefault(locale)
Does Locale.setDefault change the locale for the system?
No only for that one javaprogramm
What is the NumberFormat-method for getting a general-purpose formatter?
NumberFormat.getInstance()
NumberFormat.getInstance(locale)
What is the NumberFormat-method for getting a general-purpose formatter (with number instance)
NumberFormat.getNumberInstance()
NumberFormat.getNumberInstance(locale)
What is the NumberFormat-method for getting a formatter for formatting monetary amounts?
NumberFormat.getCurrencyInstance()
NumberFormat.getCurrencyInstance(locale)
What are the decimal format symbols?
# - omits the position if no digit exists for it . $2.2
0 - put a 0 in the position if no digit exists for it - $002.20
How to custom format numbers?
new DecimalFormat("###,###,###.0");
How to get a DateTimeFormatter-instance for formatting dates=
DateTimeFormatter.ofLocalizedDate(dateStyle)
How to get a DateTimeFormatter-instance for formatting times?
DateTimeFormatter.ofLocalizedTime(timestyle)
How to get a DateTimeFormatter-instance for formatting dates and times?
DateTimeFormatter.ofLocalizedDateTime(dateStyle, timeStyle)
DateTimeFormatter.ofLocalizedDateTime(dateTimeStyle)
What are possible FormatStyle-parameters?
SHORT, MEDIUM, LONG, FULL
How to get a formatter for a specific locale?
Datetimeformatter.withLocale(locale)
How to set the default locale only for displaying data about the locale?
with Locale.Category value DISPLAY
How to set the default locale only for formatting dates,numbers or currencies?
With Locale.Category value FORMAT
Where is the resourcebundle stored?
in a properties file
What is a properties file?
A textfile that contains a list of key/value pairs
How to get the bundle for a locale?
ResourceBundle.getBundle("name");
ResourceBundle.getBundle("name", locale);
How to get a set of all keys in a ResourceBundle?
resourceBundle.keySet()
What are the steps of getting the proper ResourceBundle?
- Look for the resource bundle for the requested locale, followed by the one for the default locale
- for each locale, check language/country, followed by just the language
- use the default resource bundle if no matching locale can be found
Can java get keys from multiple resource bundles?
Yes, f.e. from the parent resource bundle
How to use params in the resourcebundle?
f.e. with {0} and {1} and then use :
String format = rb.getString("helloByName");
System.out.println(MessageFormat.format(format, "Tammy", "Henry"));
How to set properties in the properties class?
var props = new Properties();
props.setProperty("name", "Ourzoo");
Whats the difference in the properties class between get() and getProperty()?
only getProperty allowes a default value
When to use a supplier? Which function is provided?
when you want to generate or supply values without taking any input.
T get();
When to use a consumer? Whats the function?
when you want to do something with a parameter but not return anything
void accept(T t);
What does a function (the functional iterface) do? Which function impletemns it?
responsible for turning one parameter into a value of a potentially different type and returning it
R apply(T t);
What does a UnaryOperator/BinaryOperator do?
Unary: transforms its value into one of the same type
BinaryOperatior: merges two values into one of the same type
Unary: T apply(T t);
Binary: T apply(T t1, T t2);
What are convenience metthods for Consumer?
Consumer andThen(Consumer);
What are convenience metthods for Function?
Function andThen(Function);
Function compose(Function);
What are convenience metthods for Predicate?
Predicate and(Predicate);
Predicate negate();
Predicate or(Predicate);
Wbhat does the compose function do for the interface function?
chains functional interfaces
What is the optional-method for returning a value and what happens if the optional is empty?
get() , throws exception
What is the optional-method for calling a counsumer with value and what happens if the optional is empty?
ifPresent(Consumer c) , does nothing
What is the optional-method for returning true if present and what happens if the optional is empty?
isPresent() , returns false
What is the optional-method for returning some other parameter if not exists and what happens if the optional is not empty?
orElse(T other)
What is the optional-method for calling supllier if not exists and what happens if the optional is not empty?
orElseGet(Supplier s) , return value
What is the optional-method for throwing a exception if not exists and what happens if the optional is not empty?
orElseThrow(Supplier s) , return value
How to create a finite stream for zero elements?
Stream.empty()
How to create a finite stream for the elements listed?
Stream.of(varargs)
How to create a finite stream for a collection?
coll.stream()