Line | |
---|
1 | :PROPERTIES:
|
---|
2 | :ID: f346dcfa-5575-4aab-a245-36ff96266611
|
---|
3 | :END:
|
---|
4 | #+title: NullPointerException
|
---|
5 | * NullPointerException
|
---|
6 | Thrown when an application attempts to use null in a case where an
|
---|
7 | object 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 |
|
---|
15 | https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it
|
---|
16 |
|
---|
17 | NullPointerExceptions are exceptions that occur when you try to use a
|
---|
18 | reference that points to no location in memory (null) as though it were
|
---|
19 | referencing an object. Calling a method on a null reference or trying to
|
---|
20 | access 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.