5

Скажите, что такое null в java? Пример:

// это только фрагмент
public main() {
    JFrame f = new JFrame();
    f.setLocationRelativeTo(null);
    // и так далее 
}
1
  • То есть вы столкнулись в null только в Swing?
    – naiad09
    8 июн 2016 в 15:16

3 ответа 3

6
  • null - читается нал
  • означает отсутствующее значение или ссылку
  • null может быть сконвертирован (кастирован) в любой тип/класс/объект
  • нельзя создать/декларировать тип с типом null
6

Это значит отсутствие значения (не 0, а именно отсутствие).

1

Первая ссылка в гугле по запросу "null в java".

There is also a special null type, the type of the expression null, which has no name. Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type. The null reference is the only possible value of an expression of null type. The null reference can always be cast to any reference type. In practice, the programmer can ignore the null type and just pretend that null is merely a special literal that can be of any reference type.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.