07/22/2024 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 Incidental Whitespace – Selected API Classes Incidental Whitespace – Selected API Classes Incidental Whitespace So far the lines in the text blocks have all been left-justified. This need not be the case. Indentation can be used if desired. However, one needs to be careful as incidental whitespace from each line is removed… Continue Reading
03/22/2024 Rivka Scheinberg Post in Garbage Collection,Oracle Exams Leave a Comment on Instantiating Anonymous Classes – Nested Type Declarations Instantiating Anonymous Classes – Nested Type Declarations Instantiating Anonymous Classes The discussion on instantiating local classes (see Example 9.12) is also valid for instantiating anonymous classes. The class AnonClassClient in Example 9.14 creates one instance at (11) of the non-static anonymous class defined at (5) by calling… Continue Reading
08/22/2023 Rivka Scheinberg Post in Determining the Range,Garbage Collection,Oracle Exams Leave a Comment on Accessing Members in Enclosing Context – Nested Type Declarations Accessing Members in Enclosing Context – Nested Type Declarations Accessing Members in Enclosing Context Static member classes do not have a this reference, as they do not have any notion of an enclosing instance. This means that any code in a static member class can only directly access static… Continue Reading
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
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
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
12/22/2021 Rivka Scheinberg Post in Determining the Range,Garbage Collection,Oracle Exams Leave a Comment on Instantiating Local Classes – Nested Type Declarations Instantiating Local Classes – Nested Type Declarations Instantiating Local Classes Clients outside the scope of a local class cannot instantiate the class directly because such classes are, after all, local. A local class can be instantiated in the block in which it is defined. Like a local… Continue Reading
08/22/2021 Rivka Scheinberg Post in Garbage Collection,Implementing an Interface,Oracle Exams Leave a Comment on Instantiating Non-Static Member Classes – Nested Type Declarations Instantiating Non-Static Member Classes – Nested Type Declarations Instantiating Non-Static Member Classes An instance of a non-static member class can only exist when associated with an instance of its enclosing class. This means that an instance of a non-static member class must be created in the context of… Continue Reading