More on this book
Kindle Notes & Highlights
OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808 (Sybex Study Guide)
Started reading
October 14, 2019
you want to remove the 2, you can write numbers.remove(new Integer(2)) to force wrapper class use.
The advantage of specifying a size of 0 for the parameter is that Java will create a new array of the proper size for the return value.
If you like, you can suggest a larger array to be used instead. If the ArrayList fits in that array, it will be returned. Otherwise, a new one will be created.
Converting from an array to a List is more interesting. The original array and created array backed List are linked. When a change is made to one, it is available in the other. It is a fixed-size list and is al...
This highlight has been truncated due to consecutive passage length restrictions.
asList() takes varargs, which let you pass in an array or just type out the String values.
The date and time classes have private constructors to force you to use the static methods.
LocalDate d = new LocalDate(); // DOES NOT COMPILE
There are five ways to create a Period class: Period annually = Period.ofYears(1); // every 1 year Period quarterly = Period.ofMonths(3); // every 3 months Period everyThreeWeeks = Period.ofWeeks(3); // every 3 weeks Period everyOtherDay = Period.ofDays(2); // every 2 days Period everyYearAndAWeek = Period.of(1, 0, 7); // every year and 7 days
You cannot chain methods when creating a Period.
There is also Duration, which is intended for smaller units of time.
For Duration, you can specify the number of days, hours, minutes, seconds, or nanoseconds.
DateTimeFormatter f = DateTimeFormatter.ofPattern("MMMM dd, yyyy, hh:mm"); System.out.println(dateTime.format(f));
Java allows the optional specifiers to appear before the access modifier.
an identifier may only contain letters, numbers, $, or _. Also, the first character is not allowed to be a number, and reserved words are not allowed.
Java doesn't support multiple inheritance in the language because studies have shown that multiple inheritance can lead to complex, often difficult-to-maintain code.
an abstract method may not be marked as final for the same reason that an abstract class may not be marked
a method may not be marked as both abstract and private.
abstract classes can extend other abstract classes and are not required to provide implementations for any of the abstract methods.
the abstract class inherits the abstract methods of the interface but is not required to implement them.
Unfortunately, if the method name and input parameters are the same but the return types are different between the two methods, the class or interface attempting to inherit both interfaces will not compile.
It is not possible in Java to define two methods in a class with the same name and
The compiler would also throw an exception if you define an interface or abstract class that inherits from two conflicting interfaces,
a Java object may be accessed using a reference with the same type as the object, a reference that is a superclass of the object, or a reference that defines an interface the object implements, either directly or through a superclass.
a cast is not required if the object is being reassigned to a super type or interface of the object.
Here are some basic rules to keep in mind when casting variables: Casting an object from a subclass to a superclass doesn't require an explicit cast. Casting an object from a superclass to a subclass requires an explicit cast. The compiler will not allow casts to unrelated types.
A virtual method is a method in which the specific implementation is not determined until runtime. In fact, all non-final, non-static, and non-private Java methods are considered virtual methods, since any of them can be overridden at runtime.
Polymorphic Parameters One of the most useful applications of polymorphism is the ability to pass instances of a subclass or interface to a method.
Underscores are allowed as long as they are directly between two other digits.
Calling System.gc() has no effect on eligibility for garbage collection.
Java does have references to objects, but these are pointing to an object that can move around in memory.
While it does support some parts of functional programming, these occur within a class.