Сеня рядом и Белла пришел. Былое
enum в Java: очевидное - невероятное
Всем привет! Хочу рассказать про ряд неочевидных особенностей enum в Java. Поехали! 1) enum - это полноценный класс, у него могут быть поля, методы, обычные и статические 2) любой enum неявно (!) расширяет абстрактный класс Enum, поэтому наследовать enum от кого-то другого нельзя. Например, один enum от другого. При этом добавить final для enum нельзя, т.к. он уже фактически final) 3) зато enum может реализовывать интерфейсы, как и любой другой класс в Java 4) самое интересное - каждое значение enum является наследником самого enum. Т.е. можно объявить метод show в enum Direction и переопределить его Direction...
Illegal argument exception java ошибка
A Java IllegalArgumentException is a common runtime exception that occurs when a method receives an argument that is Valid in terms of its type, but Invalid in terms of its value or content. In simpler terms, the method understood the Kind of data you gave it, but it didn’t like the Specific data you provided. Here’s a breakdown of what it means, why it happens, and how to deal with it: What it means: IllegalArgumentException is a subclass of RuntimeException: This means it’s an unchecked exception, so you don’t Have to explicitly catch it in your code (though you often should for robustness)...