24 Matching Annotations
  1. Jul 2025
  2. Jan 2022
    1. We can’t create enum objects explicitly and hence we can’t invoke enum constructor directly.

      Color c1 = Color.RED;

      Color is the enum and "RED" is internally a class object of class "Color".

      In which language though, can invoke the constructor directly? I guess by using the parameterized constructors, one can invoke other constructors easily.

    2. Since it is static, we can access it by using the enum Name. Since it is final, we can’t create child enums.

      enum in java is implemented as a class. The static and final keywords have their meanings.

      An enum cannot explicitly inherit a class not can it create child enums.

    3. All enums implicitly extend java.lang.Enum class. As a class can only extend one parent in Java, so an enum cannot extend anything else.

      In Java, a class can extend only one parent class. Also, an enum implicitly extends the java.lang.Enum class. Therefore, an enum cannot extend anything else.

  3. Jun 2021
  4. Dec 2019
    1. Arguably, the rails-team's choice of raising ArgumentError instead of validation error is correct in the sense that we have full control over what options a user can select from a radio buttons group, or can select over a select field, so if a programmer happens to add a new radio button that has a typo for its value, then it is good to raise an error as it is an application error, and not a user error. However, for APIs, this will not work because we do not have any control anymore on what values get sent to the server.
  5. Nov 2019
  6. Oct 2019
  7. Aug 2019
  8. Mar 2018