We are not done with the chapter and we're not left with only one more chapter to color in the language 2
basic series. 3
So let's see what we call it in this chapter. 4
We started with the Djala API and then the process introduced package's Villa get hope classes insight 5
packages can be accessed. 6
We also look at how we can create packages are sort of on also how we can name packages next believe 7
that one of the most fundamental concepts in Java which is string and we've discussed it extensively 8
next we'll have get access levels which aid in implementing information hiding information hiding is 9
critical for that will happen loosely coupled software components so let's go ahead and look at some 10
of the important points covered in this chapter after introducing what packages are being discussed 11
on how classes and packages can be accessed. 12
You can use an import statement to Access classes in a package. 13
And to import multiple classes in the same package we can either import them separately or we can import 14
them all at once using a star import importing them separately seemed to be a generally preferred solution 15
. 16
Not that important process does not make our process bigger. 17
And they also have no effect on that runtime performance. 18
It just saves us from typing the fully qualified names finally Djala not lying back baggage is always 19
important by default next report or class in a package we need to first ensure that there is a matching 20
directory structure on the file system and the class needs to be in the last directory. 21
The second step is to put a package statement at the top of the class that is it needs to be even before 22
any import statements next for an example we saw an issue that we may face to package naming conflict 23
. 24
So we said the recommended convention is to use the organization's rulers Internet domain name. 25
We also discuss few recommended package naming conventions next me look at strings a stringing is simply 26
an object of the class dollar that land docstring a string object in Djala is immutable that is once 27
a string object is created its value can never be changed. 28
So you're talking about String object here. 29
How would the variable referencing a string object can be reassigned a different string object that 30
in dentally string class you use a psychotic diary to start the next MVNO characters are internally 31
represented using you give 16 encoding scheme which is an implementation of Unicode characters. 32
See a string object basically contains an immutable sequence of Unicode characters next me look at how 33
strongly girls are starting dentally by looking at string bull Gibeon physicalist or stringless close 34
as String objects on the string will unstring recites on the heap see String objects created from string 35
literals are stored on the string ball like String objects created via an Nuki word get stored outside 36
of the string ball. 37
But still on the heap like any regular job object but the cool thing is that even if there are multiple 38
string literals that the same content they will share the same stone age on the string pool that is 39
only one string object is created. 40
So that saves us memory and this process of building up the string pool is referred to as bringing turning 41
on each object on the string ball is referred to as a string in turn are simply in indent next string 42
concatenation and it can be done using a blitz operator or a string builder or a string buffer Well 43
string class is immutable. 44
String builder and string buffer allow us to mutate strings that is these classes allow their contents 45
to be changed. 46
Because that according to one benchmark string builder was found to be 300 pounds faster then plus operator 47
an twice as fast us string buffer and we also review of this effective delightsome which says beware 48
the performance of string concatenation. 49
It's main recommendation was to use string builder. 50
If performance is important and to use plus operator or need to combine few strings so if you're constructing 51
a large string then you should go heartstring builder next will get access liver's which was all about 52
providing restrictions on accessing classes under remembers. 53
Here are the four access levels and the corresponding access modifiers second and fourth access Lobo's 54
that is different on public are common classes on interfaces Un-Dead members. 55
When the first and third access modifiers that is private and protected are unique to only class members 56
like bills and methods so here it means the class member is private first class. 57
That is it is inaccessible to code outside of its class. 58
Next is default that is options of access Mordy fair it implies a class member accessibility is only 59
d'accord within the same package. 60
Next is protected which implies a class member is accessible to any code within the same package and 61
also put any of the subclasses of its class. 62
Some classes will be introduced when we get to inheritance finally the modified public is used when 63
accessibility is to any code within the package or any code outside of the package not that anything 64
declared with public welfare will be part of the API of these modifiers private and public use most 65
of the time finally have information hiding it helps in building value design software which comprises 66
often loosely coupled components and it is achieved by using access modifiers it fundamental rule of 67
information hiding is to never expose your instance fields with public access level as it leads to bite 68
coupling. 69
Make instance friends private and provide access to them be setters and getters general seditionist 70
as much as possible minimize accessibility to classes their members. 71
So we looked at two very important effective July dumps that are related to information hiding and that's 72
about it. 73
Thanks for listening and we will continue learning more language basics in the next chapter. 74
So see you in the next chapter