1

00:00:01,080  -->  00:00:08,340
Real that variables of primitive types can hold it does not does Indigos or characters not just look

2

00:00:08,340  -->  00:00:12,520
at the second variety of variables which can hold or object references

3

00:00:15,150  -->  00:00:15,720
district.

4

00:00:15,720  -->  00:00:17,430
Create a student object.

5

00:00:17,520  -->  00:00:21,690
And we saw this exact statement when introducing classes and objects.

6

00:00:22,110  -->  00:00:29,970
Here s is a variable and it's an object reference and not an object that is it holds bits that reference

7

00:00:29,970  -->  00:00:31,970
a student object in memory.

8

00:00:32,470  -->  00:00:34,540
Let's see how this works.

9

00:00:34,590  -->  00:00:36,780
This statement basically has three parts in it.

10

00:00:37,110  -->  00:00:40,430
And each of them informs JVM to do something.

11

00:00:40,540  -->  00:00:42,950
And let's see what those three parts are.

12

00:00:43,450  -->  00:00:50,870
Here's a fusspot a neat dense GBM to look at space and memory for that reference variable.

13

00:00:51,120  -->  00:00:57,150
And here is the second part that dolt's GBM took a look at space for a new student object in the memory

14

00:00:57,160  -->  00:00:57,640
.

15

00:00:58,110  -->  00:01:03,120
OK so space has been a look at it for reference mailable and space has been and look at it for ex-student

16

00:01:03,210  -->  00:01:04,680
object in the memory.

17

00:01:04,890  -->  00:01:09,310
No we need to send a memory address of the student object to that reference variable.

18

00:01:09,750  -->  00:01:15,630
And for that we have the third part that is an assignment operator assigns a memory address of the student

19

00:01:15,630  -->  00:01:19,220
object to the variable s.

20

00:01:19,410  -->  00:01:24,960
So we just mentioned about objects getting stored in memory but that gets stored in especially the memory

21

00:01:25,020  -->  00:01:27,100
that is assigned to JVM.

22

00:01:27,120  -->  00:01:32,130
So in JVM starts up it gets a chunk of memory from the underlying operating system in order to run its

23

00:01:32,130  -->  00:01:40,040
programs and run it off this memory is referred to us heap and all objects are stored on the heap.

24

00:01:40,230  -->  00:01:43,440
OK so all Java objects get stored on the heap.

25

00:01:43,560  -->  00:01:49,880
And this diagram shows the heap with all the objects and in our particular example the variable as it

26

00:01:49,890  -->  00:01:56,460
references one student object on the heap JVM and a non-starter covers heap concept in detail.

27

00:01:56,850  -->  00:02:02,450
But for now just know that we have a heap and that objects are stored on the heap.

28

00:02:02,900  -->  00:02:11,130
We looked at big that of all primitives no more object references build dip this GBM specific that is

29

00:02:11,150  -->  00:02:17,670
big of an object reference on one JVM maybe smaller or larger than that of an object reference on another

30

00:02:17,670  -->  00:02:20,800
JVM holloed on a given JVM.

31

00:02:20,910  -->  00:02:28,230
All of the references will have the same Babet regardless of the objects they reference different value

32

00:02:28,230  -->  00:02:35,860
for an object reference is null non-employees the object reference is not pointing to anything.

33

00:02:35,900  -->  00:02:42,620
So in this statement S.M. be assigned a different null until it is explicitly initialized.

34

00:02:42,770  -->  00:02:48,810
Now if you use a dot operator on a null reference that will lead to an exception called null pointer

35

00:02:48,870  -->  00:02:54,400
exception exceptions would be covered later in a separate chapter called exceptions.

36

00:02:54,870  -->  00:02:55,880
And that's about it.

37

00:02:55,890  -->  00:02:58,810
That's the I know for discussion on object references.

38

00:02:58,830  -->  00:02:59,250
Thank you
