---
type: archive
area: archive
status: archived
date: 2026-05-03
created: 2026-05-03
updated: 1980-01-01
tags:
  - archive
---
![[img-20240811-174622-0188e79f.png]]

![[img-20240811-174730-773b535f.png]]

- ![[img-20240811-175043-1650b09e.png]]

- Here we  cast directly and automatically do the  next operation that should be done.
- Static initializer execute only when the first project created  gets loaded into the memory
- Instance Initializer is executed every time when a new object is created .

- ![[img-20240811-180650-bce62586.png]] 

- @Override it's optional it provide an extra check that verify the method signature with the parent class.
- Sealed is permitting a class to only be extended from some specific classes
- hashCode method from Object class that responsible for creating a hash of ana Object using Object.hash()

### Records:
- Records behave like final classes they can implement interfaces  .
- Record are immutable
- implicitly extends records class
- The definition of record will turn into constructor 
- To get a filed we just call her name without getxx()
- Factory Methods Hides the part of creating an objects we just call annother class responsible for creating an instance of  our objects
- Seald class is a restricted class in inheritance it can only be extended from specific class that we define with **permits** 
- @FunctionnalInterface  make the interface support only one abstract method.
- Abstract class methods have high priority than interfaces abstract methods.
- T is a marker used when we wanf to use Generics **T,K,V**
- Comparator interface 
- ![[img-20240812-215102-85968bec.png]]
- Clonable Interface : Make you create a exact replica of a specific object
- Compostion Pattern
- ![[img-20240812-215655-b4162fd1.png]]
- Far more flexible than inheritance
- we can call an abstract method in interface implementation
- A `non-sealed` class is a subclass of a sealed class that explicitly allows further inheritance. This means that while a sealed class restricts the set of permitted subclasses, any subclass marked as `non-sealed` can be further subclassed without restrictions.

The `binarySearch` method is then used again to search for the element `"a3"` within the sorted list. Since `"a3"` is now the third element in the list, the variable `x2` is assigned the value `2`.

The variable `list2` is then assigned the result of the `reversed()` method, which returns a `SequencedCollection` object that contains the elements of the original list in reverse order. Thus, `list2` becomes `[a3, a2, a1]`.

Finally, the `binarySearch` method is used once again to search for the element `"a3"` within the reversed `list2` collection.

The rule for binary search is different for reversed collections:

- The index of the search key is returned if the key is contained in the list.
- Otherwise, the method returns `-(insertion point) - 1`. The insertion point is defined as the position at which the key would be inserted into the list: the index of the first element greater than the key, or `list.size()` if all elements in the list are less than the specified key. This ensures that the return value will be `>= 0` if and only if the key is found.

Since `"a3"` would have been inserted at position 3 in ascending order after `"a1"`, the insertion point in the reversed list is 3. Therefore, the function returns `(-3-1) = -4`.

Similarly, if `"a0"` were searched, it would have been inserted at position 0 in ascending order. Since the location in the reversed list is 0, the function would return `(-0-1) = -1`.

- For the method to be considered overloaded it should satisfy the following criteria:
	- Method name must be the same as another method in the same class
	- Method return type (including void) must be the same as that other method
	- Method parameters must be different either by a number of parameters, or their types, or both.
	- Method parameter names do not matter from the overloading perspective, only number and types of parameters matter