1
00:00:00,150 --> 00:00:07,620
So these two String instances here now actually to hold the address of two different objects in memory.

2
00:00:07,620 --> 00:00:08,470
OK.

3
00:00:08,970 --> 00:00:10,530
So these are actually pointers.

4
00:00:10,530 --> 00:00:16,050
This my first name here is actually a pointer to this object in say the memory.

5
00:00:16,140 --> 00:00:20,800
Ok this instance doesn't hold this object within it.

6
00:00:21,060 --> 00:00:26,160
This instance only holds the address of this object inside the memory.

7
00:00:26,160 --> 00:00:26,710
OK.

8
00:00:26,910 --> 00:00:28,970
So hopefully that makes sense now.

9
00:00:29,250 --> 00:00:34,260
So now let me actually comment out these lines of code here and I want to actually show you another

10
00:00:34,260 --> 00:00:38,440
way of creating String objects in Java.

11
00:00:38,460 --> 00:00:38,910
OK.

12
00:00:39,000 --> 00:00:47,270
As you saw above that when we tried to assign the same String object to two different literals compiler

13
00:00:47,300 --> 00:00:54,060
only created one object and made both of the literals to point the same object.

14
00:00:54,090 --> 00:01:00,820
OK so now I want to actually show you how we can actually create String objects in an other way.

15
00:01:01,190 --> 00:01:07,790
And in that case the compiler would create two different objects in memory having the same text.

16
00:01:07,790 --> 00:01:13,420
So for example First we need to actually refer to the name of our class Stream.

17
00:01:14,030 --> 00:01:21,570
And the name of our object is for example C Our object one.

18
00:01:21,920 --> 00:01:25,220
And then I need to put in an assignment operator here.

19
00:01:25,340 --> 00:01:29,370
And then I need to put in this key here new.

20
00:01:29,480 --> 00:01:32,490
And then again I need to refer to the name of constraint.

21
00:01:32,540 --> 00:01:33,300
OK.

22
00:01:33,590 --> 00:01:37,360
And then I need to put in a semicolon at the end of my statement.

23
00:01:37,430 --> 00:01:43,170
So as you can see here I created a string object called C R object 1.

24
00:01:43,280 --> 00:01:43,830
OK.

25
00:01:44,000 --> 00:01:51,020
As you can see I can actually assign value to this as an object one inside the practice's here.

26
00:01:51,080 --> 00:01:51,570
OK.

27
00:01:51,710 --> 00:01:59,230
So this is a constructor in string class that allows us to actually assign value to our string instances.

28
00:01:59,240 --> 00:02:02,150
OK so I can actually just type in here.

29
00:02:02,570 --> 00:02:04,800
Hello world.

30
00:02:05,170 --> 00:02:06,230
OK.

31
00:02:06,950 --> 00:02:12,400
And now as you can see I created an object called Hello world.

32
00:02:12,520 --> 00:02:17,170
OK so now I can actually create another object here.

33
00:02:17,210 --> 00:02:21,340
I just need to refer to the name of the class 3.

34
00:02:21,940 --> 00:02:22,740
OK.

35
00:02:22,820 --> 00:02:28,760
And the name of the object is Esti are object to.

36
00:02:28,840 --> 00:02:29,610
OK.

37
00:02:29,630 --> 00:02:35,320
And then I need to put in an assignment operator here and then I put in this key word here new.

38
00:02:35,510 --> 00:02:42,170
And then I again refer to the name of the String class and then I put in Apprentice's here and then

39
00:02:42,200 --> 00:02:45,100
I put in a semicolon at the end of my statement.

40
00:02:45,200 --> 00:02:52,700
And now I can actually assign a value to our it's art object to by using a constructor that is inside

41
00:02:52,700 --> 00:02:53,570
the as three in class.

42
00:02:53,570 --> 00:03:00,620
OK so remember that a string class is a predefined class for us those constructors are pre-defined for

43
00:03:00,620 --> 00:03:01,890
us and we can use them.

44
00:03:02,060 --> 00:03:07,400
So inside the prentices I just need to put in two double quotes and then instead of double quotes again

45
00:03:07,430 --> 00:03:10,120
I can just type in Hello world.

46
00:03:10,580 --> 00:03:18,520
So as you can see here I created two different strange instances with the same value but the this time

47
00:03:18,620 --> 00:03:23,320
the address of these two objects is going to be completely different inside the memory.

48
00:03:23,330 --> 00:03:23,770
OK.

49
00:03:23,810 --> 00:03:31,160
So this object is going to be saved inside the memory in one place and in and this object is going to

50
00:03:31,160 --> 00:03:34,510
be actually saved inside the memory in another place.

51
00:03:34,530 --> 00:03:38,910
OK that's it that's how you can actually create a string object in Java.

52
00:03:38,930 --> 00:03:44,750
And now I want to actually talk more about these string objects in order to make this concept more meaningful

53
00:03:44,750 --> 00:03:45,170
for you.

54
00:03:45,200 --> 00:03:52,130
OK so now if I want to output the value of these string instances to the console I just need to type

55
00:03:52,130 --> 00:03:59,300
in here system that out that princeling and that inside the prentices I can just refer to the name of

56
00:03:59,300 --> 00:04:02,400
the object as the object one.

57
00:04:02,630 --> 00:04:05,710
And then I need to put in a semi-colon at the end of my statement.

58
00:04:05,720 --> 00:04:11,990
So now if I had on my project as you can see this value is output to the counselor OK or I can actually

59
00:04:12,170 --> 00:04:16,510
output the value of this SDR object to the console.

60
00:04:16,520 --> 00:04:22,310
So I just need to type in here sees them that out that print to learn and then inside the parenthesis

61
00:04:22,340 --> 00:04:24,770
I can just refer to the name of my object.

62
00:04:24,770 --> 00:04:25,340
OK.

63
00:04:25,610 --> 00:04:30,860
As the object to and that I need to put in a semicolon at the end of my statement.

64
00:04:31,070 --> 00:04:36,540
And now if I start my project as you can see this value again is output to the console OK.

65
00:04:36,860 --> 00:04:44,020
And remember that these two objects are actually stored in memory in two different places.

66
00:04:44,030 --> 00:04:50,460
OK because we created these string objects by using these new key word here.

67
00:04:50,510 --> 00:04:51,250
OK.

68
00:04:51,620 --> 00:04:52,980
So this is really important.

69
00:04:53,000 --> 00:04:58,460
You can actually create String objects by just using these string literals or you can actually create

70
00:04:58,670 --> 00:05:02,130
string objects by using this new keyboard here.

71
00:05:02,210 --> 00:05:02,970
OK.

72
00:05:03,350 --> 00:05:07,970
So to recap strings are a sequence of characters.

73
00:05:07,970 --> 00:05:08,680
OK.

74
00:05:08,960 --> 00:05:18,410
In Java programming language strings are objects and the Java platform provides string class to create

75
00:05:18,470 --> 00:05:21,120
and manipulate strings.

76
00:05:21,200 --> 00:05:28,030
So in order to create strings the most direct way to create a stream is to actually use the string literals.

77
00:05:28,050 --> 00:05:33,680
OK so for example let me actually comment out these lines of code here and I need to refer to the name

78
00:05:33,680 --> 00:05:37,930
of the string class the name of my object is Esti are one.

79
00:05:38,240 --> 00:05:40,820
And that I put in an assignment operator here.

80
00:05:40,970 --> 00:05:43,920
And then I can actually put into double quotes and here I can.

81
00:05:43,950 --> 00:05:48,160
Just putting a value here.

82
00:05:48,170 --> 00:05:48,580
OK.

83
00:05:48,610 --> 00:05:52,940
Inside the double quotes and then I need to put in a semicolon at the end of my statement.

84
00:05:52,960 --> 00:05:53,520
OK.

85
00:05:53,660 --> 00:05:58,500
So here as you can see this is the most direct way to create a strange.

86
00:05:58,560 --> 00:05:59,670
OK.

87
00:05:59,820 --> 00:06:09,760
Whenever the compiler encounters a string literal in your code it creates a string object with its value.

88
00:06:10,170 --> 00:06:14,010
In this case OK with its value in this case of value.

89
00:06:14,100 --> 00:06:14,530
OK.

90
00:06:14,550 --> 00:06:21,870
As with any other object you can create String objects by using the new keyboard and a constructor which

91
00:06:21,870 --> 00:06:26,490
I actually showed you two examples earlier in this tutorial.

92
00:06:26,490 --> 00:06:34,050
The string class has 11 constructors that allow you to provide the initial value of this string using

93
00:06:34,260 --> 00:06:35,260
different sources.

94
00:06:35,270 --> 00:06:42,370
Distraint class is immutable so that once it is created a string object cannot be changed.

95
00:06:42,420 --> 00:06:47,550
If there is a necessity to make a lot of modifications to strings of characters who can actually use

96
00:06:47,730 --> 00:06:50,900
the string buffer class or the string to be the class OK.

97
00:06:50,970 --> 00:06:58,330
And now I want to actually show you some of the effects of a strange class in order to manipulate these

98
00:06:58,510 --> 00:06:59,430
string objects.

99
00:06:59,460 --> 00:07:00,150
OK.

100
00:07:00,570 --> 00:07:06,290
Methods used to obtain information about an object are known as accessor methods.

101
00:07:06,320 --> 00:07:12,250
OK one access and method that you can use with strings is the length method.

102
00:07:12,360 --> 00:07:20,220
So let me repeat again methods used to obtain information about an object are known as accessor methods.

103
00:07:20,400 --> 00:07:27,750
One access in my faith that you can use with strings is the method which returns the number of characters

104
00:07:28,320 --> 00:07:31,150
contained in these in the string object.

105
00:07:31,170 --> 00:07:34,470
And now I want to actually show you those examples here.

106
00:07:34,610 --> 00:07:43,110
OK so now as you can see here in line 26 I created a string object and the name of my object is a string.

107
00:07:43,140 --> 00:07:44,500
One Esti are one.

108
00:07:44,520 --> 00:07:52,950
OK so now I want to actually create an integer value but in order to actually hold the length of this

109
00:07:53,160 --> 00:07:54,160
string object.

110
00:07:54,230 --> 00:07:55,960
OK so now.

111
00:07:56,010 --> 00:08:04,600
So the data type of my variable is int and the name of my variable is as thrain Len.

112
00:08:05,060 --> 00:08:05,790
OK.

113
00:08:05,820 --> 00:08:08,660
And then I need to put in an assignment operator here.

114
00:08:08,970 --> 00:08:14,550
And then I refer to the name of my object t r want that Len.

115
00:08:14,850 --> 00:08:18,910
As you can see here this little method is an accessible method.

116
00:08:18,950 --> 00:08:26,430
OK so an Access and method means that this method is actually going to obtain information about this

117
00:08:26,520 --> 00:08:27,080
object.

118
00:08:27,090 --> 00:08:27,690
OK.

119
00:08:28,050 --> 00:08:29,850
So the name of this method is Len.

120
00:08:30,120 --> 00:08:37,190
And the return type of this method is int and this method is inside the stream class.

121
00:08:37,200 --> 00:08:42,610
OK so if I choose this method now and I need to put in a semicolon at the end of my method.

122
00:08:42,690 --> 00:08:45,300
So this is Thring less valuable.

123
00:08:45,300 --> 00:08:49,620
Now holds the length of ds s t r one object.

124
00:08:49,620 --> 00:08:50,210
OK.

125
00:08:50,400 --> 00:08:53,610
And now if you want to output this value to the console.

126
00:08:53,640 --> 00:09:00,930
I just need to type in here a system that's out that princeling and an inside the apprentice's I just

127
00:09:00,930 --> 00:09:04,930
need to refer to the name of my valuable as string string length.

128
00:09:05,100 --> 00:09:08,010
OK so now I need to choose this option here.

129
00:09:08,010 --> 00:09:09,050
String length.

130
00:09:09,240 --> 00:09:12,380
And then I need to put in a semi-colon at the end of my statement.

131
00:09:12,480 --> 00:09:18,460
So now if I add on my project as you can see this value is output to the consulate number 7.

132
00:09:18,480 --> 00:09:29,800
So if you actually count the length of this string here as you can see one two three four five six seven.

133
00:09:29,950 --> 00:09:34,580
OK so this value is the value of the string length variable.

134
00:09:34,600 --> 00:09:39,820
Ok so this is the length of our string object.

135
00:09:39,850 --> 00:09:40,610
OK.

136
00:09:40,870 --> 00:09:45,800
And another method that we can use on String objects is.

137
00:09:46,060 --> 00:09:49,240
For example let me actually comment out of this line of code here.

