< prev index next >

src/java.base/share/classes/java/lang/NullPointerException.java

Print this page




  34  * <li>Taking the length of {@code null} as if it were an array.
  35  * <li>Accessing or modifying the slots of {@code null} as if it
  36  *     were an array.
  37  * <li>Throwing {@code null} as if it were a {@code Throwable}
  38  *     value.
  39  * </ul>
  40  * <p>
  41  * Applications should throw instances of this class to indicate
  42  * other illegal uses of the {@code null} object.
  43  *
  44  * {@code NullPointerException} objects may be constructed by the
  45  * virtual machine as if {@linkplain Throwable#Throwable(String,
  46  * Throwable, boolean, boolean) suppression were disabled and/or the
  47  * stack trace was not writable}.
  48  *
  49  * @author  unascribed
  50  * @since   1.0
  51  */
  52 public
  53 class NullPointerException extends RuntimeException {

  54     private static final long serialVersionUID = 5162710183389028792L;
  55 
  56     /**
  57      * Constructs a {@code NullPointerException} with no detail message.
  58      */
  59     public NullPointerException() {
  60         super();
  61     }
  62 
  63     /**
  64      * Constructs a {@code NullPointerException} with the specified
  65      * detail message.
  66      *
  67      * @param   s   the detail message.
  68      */
  69     public NullPointerException(String s) {
  70         super(s);
  71     }
  72 }


  34  * <li>Taking the length of {@code null} as if it were an array.
  35  * <li>Accessing or modifying the slots of {@code null} as if it
  36  *     were an array.
  37  * <li>Throwing {@code null} as if it were a {@code Throwable}
  38  *     value.
  39  * </ul>
  40  * <p>
  41  * Applications should throw instances of this class to indicate
  42  * other illegal uses of the {@code null} object.
  43  *
  44  * {@code NullPointerException} objects may be constructed by the
  45  * virtual machine as if {@linkplain Throwable#Throwable(String,
  46  * Throwable, boolean, boolean) suppression were disabled and/or the
  47  * stack trace was not writable}.
  48  *
  49  * @author  unascribed
  50  * @since   1.0
  51  */
  52 public
  53 class NullPointerException extends RuntimeException {
  54     @java.io.Serial
  55     private static final long serialVersionUID = 5162710183389028792L;
  56 
  57     /**
  58      * Constructs a {@code NullPointerException} with no detail message.
  59      */
  60     public NullPointerException() {
  61         super();
  62     }
  63 
  64     /**
  65      * Constructs a {@code NullPointerException} with the specified
  66      * detail message.
  67      *
  68      * @param   s   the detail message.
  69      */
  70     public NullPointerException(String s) {
  71         super(s);
  72     }
  73 }
< prev index next >