Test 4 Flashcards
Para compilar un archivo “javac archivo.java”
Para correr un archivo “java archivo”
asd
a default method of an interface cannot be overridden by a static method of another interface, You can, however, redeclare a static method of a super interface as a default method in the sub interface.
interface methods can never be declared final.
only final or effective final local variables can be used in a lambda expression
The actual classes for Connection, Statement, and ResultSet interfaces are provided by the JDBC driver and are therefore driver dependent.
xxc
BufferedWriter’s append method = works same as the write(String) method. It doesn’t really append the data to the end of the existing content. It overwrites the existing content.
The close method flushes the stream and makes sure that all data is actually written to the file.
To aggregate features of another class, you either extend that class (i.e. inheritance) or have an object of the other class in your class (i.e. composition).
as
Singleton patterns
- Make the constructor of the class private so that no one can instantiate it except this class itself.
- Add a private static variable of the same class to the class and instantiate it.
- Add a public static method (usually named getInstance()), that returns the class member created in step 2.
Assertions sintax: :
booleano : cualqier cosa que no sea void
- Instantis a point on Java time line. This timeline start fromfrom the first second of January 1, 1970 (1970-01-01T00:00:00Z) also called the EPOCH. Note that there is no time zone here. You may think of it as “Java Time Zone” and it matches with GMT or UTC time zone. That means, 1PM in Java time zone will be same as 1 PM in GMT or UTC time zone.
- Once created, an Instant cannot be modified. Its methods such as plus and minus return a new Instant object.
- Instant works with time (instead of dates), so you can use Duration instance to create new Instants.
- LocalDateTime is a time in a given time zone. (But remember that an instance of LocalDateTime itself does not store the zone information!). You can, therefore, use an Instant and a time zone to create a LocalDateTime object.
- Whenever you convert an Instant to a LocalDateTime using a time zone, just add or substract the GMT offset of the time zone i.e. if the time zone is GMT+2, add 2 hours and if the time zone is GMT-2, substract two hours. For example, you can yourself this question - if it is 1PM (for example) here in London, which is in GMT, then what would be the time in New York (for example), which is in GMT-4 (or 5, depending on whether the date lies when Day Light Savings time is on or not). The answer would be 1PM - 4 i.e. 9AM.
as
Solo puede haber una clase publica o enum o interfaz o clase abstracta por archivo
An enum cannot be defined inside any method or constructor.
An enum can be defined as a static member of any class. You can also have multiple public enums with in the same class.
In order for a program to load a resource bundle, the resource bundle properties file must be in the CLASSPATH.
Classes used to represent dates and times in java.time package are thread safe.
Daylight Saving Time is related to Time zones. It has nothing to do with Duration or Period.
All classess in java.time package such as classes for date, time, date and time combined, time zones, instants, duration, and clocks are immutable and thread-safe.
Remember that static fields are never serialized irrespective of whether they are marked transient or not. In fact, making static fields as transient is redundant.
asd
Remember the following points about Path.subpath(int beginIndex, int endIndex)
- Indexing starts from 0.
- Root (i.e. c:) is not considered as the beginning.
- name at beginIndex is included but name at endIndex is not.
- paths do not start or end with .
Remember the following 4 points about Path.getName() method :
- Indices for path names start from 0.
- Root (i.e. c:) is not included in path names.
- \ is NOT a part of a path name.
- If you pass a negative index or a value greater than or equal to the number of elements, or this path has zero name elements, java.lang.IllegalArgumentException is thrown. It DOES NOT return null.
The auto-closeable variables defined in the try-with-resources statement are implicitly final. Thus, they cannot be reassigned.
Puedes cerrar los recursos en el body del try pero igual se cerraran nuevamente al finalizar el try si utilizas try with resources
Console is meant to interact with the user typically through command/shell window and keyboard. Thus, You can read as well as write only character data from/to it.
we
orElse, orElseGet deben retornar el mismo tipo del Optional
Optional’s orElseGet method takes a java.util.function.Supplier function as an argument and invokes that function to get a value if the Optional itself is empty. Just like the orElse method, this method does not throw any exception even if the Supplier returns null. It does, however, throw a NullPointerException if the Optional is empty and the supplier function itself is null.