fdsa


Fichier Détails

Cartes-fiches 496
Langue Deutsch
Catégorie Informatique
Niveau Autres
Crée / Actualisé 06.12.2020 / 24.01.2021
Lien de web
https://card2brain.ch/box/20201206_java_2_3
Intégrer
<iframe src="https://card2brain.ch/box/20201206_java_2_3/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>

When implementing compareTo, where do we have to pay attention to?

keeping compareTo and equals consistent

Can comparable or comparator be used without a import statement?

Comparator yes, comparable not

Whats the package name, whats the method name, whats the number of parameters, has the interface to be implemented by class compaing in class Comparable?

java.lang / compareTo() / 1 / Yes

Whats the package name, whats the method name, whats the number of parameters, has the interface to be implemented by class compaing in class Comparator?

java.util / compare()  / 2  / no

Whats the static comparator-method for comparing by results of a function that returns any object?

comparing(function)

Whats the static comparator-method for comparing by the results of a function that returns a double?

comparingDouble(function)

Whats the static comparator-method for comparing by the results of a function that returns an int?

comparingInt(function)

Whats the static comparator-method for  comparing by the results of a function that returns a long?

comparingLong(function)

Whats the static comparator-method for sorting using the order specified by the comparable implementation on the object itself?

naturalOrder()

Whats the static comparator-method for sorting using the reverse of the order specified by the Comparable implementation on the object itself?

reverseOrder()

Whats the default-method in comparator for reversing the order of the chained comparator?

reversed()

Whats the default-method in comparator if the previous comparator returns 0 se this comparator that returns a double/int/long , otherwise return the value form the previous comparator

thenComparingDouble(function) / thenComparingInt(function)  / thenComparingLong(function)

When can we use Collections.sort()?

When the objects to be sorted are Comparable

What are the preconditions for Collections.binarySearch?

Must be sorted 

What cant be done with genericTypes?

  • calling a constructor
  • creating an array of that generic type
  • calling instanceof
  • using a primitive type as a generic type parameter
  • creating a static variable as a generic type parameter

What happns if you add list.removeIf on a list which was created by list.of()?

unsupportedOperation