fixed the first footnote in java_5
This commit is contained in:
parent
f877e10d00
commit
5f52d0a808
1 changed files with 1 additions and 1 deletions
|
@ -86,7 +86,7 @@ public class Main {
|
|||
}
|
||||
}
|
||||
```
|
||||
As you can see, the program now prints out 11 instead of 10. That's because of something Java uses called *pointers*[^1]: Our `thing` variable in the `main` method doesn't really store the actual *instance*, but instead, it stores the location of that instance in memory. So when passing that variable into the `addOne` method, all we pass is the information "The thing we're trying to modify sits in this part of memory, so modify the data there, please." That's why, when we then change the `Thing`'s `i` variable, it's also modified outside of the method.
|
||||
As you can see, the program now prints out 11 instead of 10. That's because of something Java uses called *pointers*[^1]. Our `thing` variable in the `main` method doesn't really store the actual *instance*, but instead, it stores the location of that instance in memory. So when passing that variable into the `addOne` method, all we pass is the information "The thing we're trying to modify sits in this part of memory, so modify the data there, please." That's why, when we then change the `Thing`'s `i` variable, it's also modified outside of the method.
|
||||
|
||||
# `null`
|
||||
Any variables that can store objects rather than primitive types (our `thing` variable from before, for example) can have a state where they don't point to an object, but instead, point to nothing. This "nothing" is called `null`.
|
||||
|
|
Loading…
Reference in a new issue