Now let's look at strings of string manipulation is one of the most common activities in programming 2
. 3
That's because strings represent text and we know that it is impossible to imagine any application VIDOT 4
next strings in are unique due to the way they get stored internally. 5
If you don't have a clear understanding of strings in Java then you may end up writing very inefficient 6
code. 7
So to try to cover everything related to strings so that we can use it in the right way. 8
A string is simply an object of the class jobs are not blank docstring the fact that stringless is part 9
of our Rockline package tells us that it is a fundamental class job. 10
So we can simply instantiate the String class to create String objects. 11
In this case a variable S represents an empty string not if you want a variable as to represent some 12
text like hello then we can invoke a different constructor. 13
In this example the argument passed to the constructor is a Citrin return. 14
So a string literal consists of zero or more characters enclosed in double quotes Well Carter letters 15
are enclosed in single quotes. 16
String literals are enclosed in double quotes know this particular constructor has a single parameter 17
that is an object reference of byte string so it means that you DOCSIS String objects it also means 18
that a string literal is also a String object. 19
So intimately as ringleader is Bastos a string object or insert a string we can you can also pass an 20
object reference of by a string that is all we are creating an object reference of pipe string. 21
We are creating it by passing another object reference as input to the constructor Alternatively you 22
can also do this very first create a character tree representing the text Hello. 23
Then the characters race past us and put to run off the constructor's finally we can also create strengths 24
just like the way we create perimeter variables simply assign a string literal with a variable as not 25
that he had available as is still an object reference. 26
So don't think that it's a primitive variable just because we are sending a letter. 27
You can also see that the variable type is a class or not. 28
But it go get a Also this is the recommended way to create strings are strings created using string 29
literals are internally implemented in an efficient way as we will soon see. 30
So all the previous approaches of creating strings using the new keyword are not recommended. 31
Not that in Donelly string class use a psychotic rate to that text but we know that in characters I 32
didn't and the data presented using you'd be 16 and coding scheme which is an implementation of Unicode 33
characters that what this means is that a string in Java is basically a sequence off Unicode characters 34
here we are using the term sequence as strings and Dunalley using characters to store that text. 35
Estrin in July is also immutable. 36
That is once a string of dip is created its value can never be changed. 37
String mutability will be discussed later so always keep in mind that a string object basically contains 38
an immutable sequence of Unicode characters. 39
String is given special treatment in Java it's common usage. 40
Let's look at some off its special features we have already seen that like primitives a string can be 41
constructed by directly assigning a string literal. 42
You can do this for regular job objects but one exception is baulks primitives or wrapper classes which 43
we briefly discussed while covering switch statements. 44
They can be directly assigned litotes also. 45
For example an object reference of type integer can be directly assigned an int.. 46
We'll be looking at baulks primitives later. 47
If you recall we mentioned that bless our pricker which is one of the Artomatic operators can also be 48
additionally used for string concatenation that is as you can see here we can use bless to concatenate 49
strings. 50
Hello and goodbye. 51
So bailable as we be the little hello world literally a lot to discuss about string concatenation as 52
there is a performance implication associated with it finally all strings created using string literals 53
are stored in a special area of memory called string this does not happen with strings that are created 54
using nucula. 55
That is they don't get stored in that string when the main benefit that drink will provide is that if 56
strings are created using the same string return then they both would be represented by the same string 57
object in the string. 58
So basically memory is served here. 59
But if you create two strings with a Nuki word and they both have the same text then they are still 60
represented by different string objects. 61
This was the reason why it was recommended to create strings by assigning literals are not true. 62
Using the new keyword and you have even discussed Trinkle later in detail in a lesson so that's about 63
it. 64
We now understand what a string is and how it can be created in the next few lessons. 65
We will try to explore everything about strings