среда, 30 октября 2019 г.

Number notation

int million2 = 1_000_000;

You can add underscores anywhere except at the beginning of a literal, the end of a literal, right before a decimal point, or right after a decimal point.


Let’s look at a few examples:

double notAtStart = _1000.00; // DOES NOT COMPILE

double notAtEnd = 1000.00_; // DOES NOT COMPILE

double notByDecimal = 1000_.00; // DOES NOT COMPILE

double annoyingButLegal = 1_00_0.0_0; // this one compiles

Constructor

The purpose of a constructor is to initialize fields.
The constructor runs after all fields and instance initializer blocks have run.

public static void main(String[] args)

In practice, you can write String[] args, String args[] or String... args; the compiler accepts any of these.

Multiple classes in one class file

You can even put two classes in the same file. When you do so, at most one of the classes in the fi le is allowed to be public.

Интерфейсы

Интерфейсы не могут иметь конструкторы.
Все поля в интерфейсе public final static, и должны быть инициализированы( так как отсутствуют конструкторы)

Все методы в интерфейсе public abstract.

Модификатор доступа имплементируемого метода должен быть не уже метода в интерфейсе.

Мы не может создать объект интерфейса
Deliverable deliverable = new Deliverable();
Но возможно создать массив объектов из Интерфейса.
Deliverable[] deliverable = new Deliverable[4];

В интерфейсе, помимо абстрактных, возможны статические и дефолтные методы.
Их имплементировать не надо.

Абстрактные классы

В абстрактных классах возможно определить статические методы


public static void doSmth(){
System.out.println("Static method in Abstract class");
}


В Абстрактных классах возможно создать обычные поля. Но их можно инициализировать в конструкторе.

Cписок методов в классе

CTRL+F12 список методов в классе.