source: content/digarden/pages/20221028223544-nullpointerexception.org@ 972a737

Last change on this file since 972a737 was 972a737, checked in by w96k <w96k@…>, on Apr 16, 2023 at 5:54:55 PM

Add logseq

  • Property mode set to 100644
File size: 1.0 KB
Line 
1:PROPERTIES:
2:ID: f346dcfa-5575-4aab-a245-36ff96266611
3:END:
4#+title: NullPointerException
5* NullPointerException
6Thrown when an application attempts to use null in a case where an
7object is required. These include:
8
9- Calling the instance method of a null object.
10- Accessing or modifying the field of a null object.
11- Taking the length of null as if it were an array.
12- Accessing or modifying the slots of null as if it were an array.
13- Throwing null as if it were a Throwable value.
14
15https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it
16
17NullPointerExceptions are exceptions that occur when you try to use a
18reference that points to no location in memory (null) as though it were
19referencing an object. Calling a method on a null reference or trying to
20access a field of a null reference will trigger a NullPointerException.
21
22#+begin_src java
23 public class Example {
24 public static void main(String[] args) {
25 Object obj = null;
26 obj.hashCode();
27 }
28}
29#+end_src
30
Note: See TracBrowser for help on using the repository browser.