03/22/2022 Rivka Scheinberg Post in Non-Static Member Classes,Oracle Exams Leave a Comment on Local Classes – Nested Type Declarations Local Classes – Nested Type Declarations 9.4 Local Classes Declaring Local Classes A local class is an inner class that is defined in a block. This can be essentially any context where a local block or block body is allowed: a method, a constructor, an initializer… Continue Reading
01/22/2022 Rivka Scheinberg Post in Oracle Exams,Static Member Types Leave a Comment on Accessing Declarations in Enclosing Context – Nested Type Declarations Accessing Declarations in Enclosing Context – Nested Type Declarations Accessing Declarations in Enclosing Context Declaring a local class in a static or a non-static block influences what the class can access in the enclosing context. Accessing Local Declarations in the Enclosing Block Example 9.10 illustrates how a local class… 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
10/22/2021 Rivka Scheinberg Post in Determining the Range,Implementing an Interface,Oracle Exams Leave a Comment on Accessing Members in the Enclosing Class – Nested Type Declarations Accessing Members in the Enclosing Class – Nested Type Declarations Accessing Members in the Enclosing Class Example 9.11 illustrates how a local class can access members in its enclosing class. The top-level class TLCWith2LCS declares two methods: nonStaticMethod() and staticMethod(). Both methods define a local class each: NonStaticLocal at (1)… Continue Reading
10/22/2021 Rivka Scheinberg Post in Determining the Range,Non-Static Member Classes,Oracle Exams Leave a Comment on Instantiating Static Member Classes – Nested Type Declarations Instantiating Static Member Classes – Nested Type Declarations Instantiating Static Member Classes A static member class can be instantiated without first creating an instance of the enclosing class. Example 9.2 shows a client creating an instance of a static member class at (14) using the new operator and… Continue Reading
09/22/2021 Rivka Scheinberg Post in Determining the Range,Oracle Exams,Static Member Types Leave a Comment on The StringBuilder Class – Selected API Classes The StringBuilder Class – Selected API Classes 8.5 The StringBuilder Class Although there is a close relationship between objects of the String and StringBuilder classes, these are two independent final classes, both directly extending the Object class. Hence, String references cannot be stored (or cast) to StringBuilder… 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
05/22/2021 Rivka Scheinberg Post in Garbage Collection,Non-Static Member Classes,Oracle Exams Leave a Comment on Inserting Characters in a String Builder – Selected API Classes Inserting Characters in a String Builder – Selected API Classes Inserting Characters in a String Builder The overloaded method insert() can be used to insert characters at a given offset in a string builder. Click here to view code image StringBuilder insert(int offset, Object obj)StringBuilder insert(int dstOffset, CharSequence seq)StringBuilder insert(int… Continue Reading
03/22/2021 Rivka Scheinberg Post in Garbage Collection,Oracle Exams,Static Member Types Leave a Comment on Static Local Types – Nested Type Declarations Static Local Types – Nested Type Declarations 9.5 Static Local Types It is possible to declare local interfaces, local enum types, and local record classes. However, these local nested types are implicitly static—as opposed to local classes that are never static. A local class declared in a… Continue Reading
03/22/2021 Rivka Scheinberg Post in Implementing an Interface,Non-Static Member Classes,Oracle Exams Leave a Comment on Pseudorandom Number Generator – Selected API Classes Pseudorandom Number Generator – Selected API Classes Pseudorandom Number Generator The class Math provides the random() method for generating pseudorandom numbers of type double that are in the open interval [0.0, 1.0). The Random class (p. 482) should also be considered, as it is more versatile and… Continue Reading