02/22/2023 Rivka Scheinberg Post in Garbage Collection,Implementing an Interface,Oracle Exams Leave a Comment on Inheritance Hierarchy and Enclosing Context – Nested Type Declarations Inheritance Hierarchy and Enclosing Context – Nested Type Declarations Inheritance Hierarchy and Enclosing Context A non-static member class can extend another class and implement interfaces, as any normal class. An inherited field (or method) in a non-static member subclass can hide a field (or method) with the same name… Continue Reading
02/22/2023 Rivka Scheinberg Post in Garbage Collection,Non-Static Member Classes,Oracle Exams Leave a Comment on Reversing Characters in a String Builder – Selected API Classes Reversing Characters in a String Builder – Selected API Classes Reversing Characters in a String Builder The following method in the class StringBuilder reverses the contents of a string builder: StringBuilder reverse() Examples of using methods that modify string builders: Click here to view code image StringBuilder builder = new… Continue Reading
12/22/2022 Rivka Scheinberg Post in Garbage Collection,Oracle Exams,Static Member Types Leave a Comment on Overview of Nested Type Declarations – Nested Type Declarations Overview of Nested Type Declarations – Nested Type Declarations 9.1 Overview of Nested Type Declarations A type declaration allows a new reference type to be defined. A type declaration can either be a top-level type declaration or a nested type declaration. Figure 9.1 gives an overview of the different… Continue Reading
10/22/2022 Rivka Scheinberg Post in Implementing an Interface,Non-Static Member Classes,Oracle Exams Leave a Comment on Non-Static Member Classes – Nested Type Declarations Non-Static Member Classes – Nested Type Declarations 9.3 Non-Static Member Classes Declaring Non-Static Member Classes Non-static member classes are inner classes—that is, non-static nested classes— that are defined without the keyword static as instance members of either a class, an enum type, or a record class. Non-static… Continue Reading
09/22/2022 Rivka Scheinberg Post in Implementing an Interface,Oracle Exams,Static Member Types Leave a Comment on Static Member Types – Nested Type Declarations Static Member Types – Nested Type Declarations 9.2 Static Member Types Declaring Static Member Types Static member types can be declared in top-level type declarations, or within other nested types. For all intents and purposes, a static member type is very much like a top-level type. A… Continue Reading
09/22/2022 Rivka Scheinberg Post in Non-Static Member Classes,Oracle Exams,Static Member Types Leave a Comment on Constructing BigDecimal Numbers – Selected API Classes Constructing BigDecimal Numbers – Selected API Classes Constructing BigDecimal Numbers Selected constructors of the BigDecimal class are shown below. BigDecimal(int value)BigDecimal(long value)BigDecimal(double value) Create a BigDecimal with the decimal number representation of the specified value. Note that these constructors can result in a loss of precision if… Continue Reading
07/22/2022 Rivka Scheinberg Post in Determining the Range,Garbage Collection,Implementing an Interface,Non-Static Member Classes,Oracle Exams,Static Member Types Leave a Comment on Exponential Functions – Selected API Classes Exponential Functions – Selected API Classes Exponential Functions Click here to view code image static double pow(double d1, double d2) Returns the value of d1 raised to the power of d2 (i.e., d1d2). Click here to view code image static double exp(double d) Returns the exponential… Continue Reading
06/22/2022 Rivka Scheinberg Post in Determining the Range,Oracle Exams Leave a Comment on Reading Characters from String Builders – Selected API Classes Reading Characters from String Builders – Selected API Classes Reading Characters from String Builders The following methods can be used for reading characters in a string builder: Click here to view code image char charAt(int index) From the CharSequenceinterface (p. 444).void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) Copies characters… Continue Reading
05/22/2022 Rivka Scheinberg Post in Garbage Collection,Oracle Exams Leave a Comment on Controlling String Builder Capacity – Selected API Classes Controlling String Builder Capacity – Selected API Classes Controlling String Builder Capacity The following methods are exclusive to the StringBuilder class and can be used to control various capacity-related aspects of a string builder: int capacity() Returns the current capacity of the string builder, meaning the number of… Continue Reading
05/22/2022 Rivka Scheinberg Post in Implementing an Interface,Oracle Exams Leave a Comment on Comparing String Builders – Selected API Classes Comparing String Builders – Selected API Classes Comparing String Builders String builders implement the Comparable<StringBuilder> interface and can be compared lexicographically, analogous to String objects (p. 447). Click here to view code image int compareTo(StringBuilder anotherSB) Here are some examples of string builder comparisons: Click here to… Continue Reading