[FREE PDF sample] Java 17 Quick Syntax Reference: A Pocket Guide to the Java SE Language, APIs, and Library Mikael Olsson ebooks
[FREE PDF sample] Java 17 Quick Syntax Reference: A Pocket Guide to the Java SE Language, APIs, and Library Mikael Olsson ebooks
com
https://ebookmeta.com/product/java-17-quick-syntax-
reference-a-pocket-guide-to-the-java-se-language-apis-and-
library-mikael-olsson/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/java-17-quick-syntax-reference-a-pocket-
guide-to-the-java-se-language-apis-and-library-3rd-edition-mikael-
olsson/
ebookmeta.com
https://ebookmeta.com/product/c-10-quick-syntax-reference-a-pocket-
guide-to-the-language-apis-and-library-mikael-olsson/
ebookmeta.com
https://ebookmeta.com/product/java-17-quick-syntax-reference-3rd-
edition-mikael-olsson/
ebookmeta.com
https://ebookmeta.com/product/war-in-the-modern-world-course-
guidebook-the-great-courses-wondrium-1st-edition-david-r-stone/
ebookmeta.com
https://ebookmeta.com/product/hair-story-nonieqa-ramos/
ebookmeta.com
https://ebookmeta.com/product/activist-affordances-how-disabled-
people-improvise-more-habitable-worlds-1st-edition-arseli-dokumaci/
ebookmeta.com
https://ebookmeta.com/product/designing-machine-learning-systems-an-
iterative-process-for-production-ready-applications-chip-huyen/
ebookmeta.com
https://ebookmeta.com/product/hi-c-data-analysis-1st-edition-silvio-
bicciato/
ebookmeta.com
Bioinformatics in Rice Research Theories and Techniques
1st Edition Manoj Kumar Gupta (Editor)
https://ebookmeta.com/product/bioinformatics-in-rice-research-
theories-and-techniques-1st-edition-manoj-kumar-gupta-editor/
ebookmeta.com
Java 17 Quick
Syntax Reference
A Pocket Guide to the Java
SE Language, APIs, and Library
—
Third Edition
—
Mikael Olsson
Java 17 Quick Syntax
Reference
A Pocket Guide to the Java SE
Language, APIs, and Library
Third Edition
Mikael Olsson
Java 17 Quick Syntax Reference: A Pocket Guide to the Java SE Language,
APIs, and Library
Mikael Olsson
Hammarland, Länsi-Suomi, Finland
Chapter 3: Variables�����������������������������������������������������������������������������9
Data Types�������������������������������������������������������������������������������������������������������������9
Declaring Variables���������������������������������������������������������������������������������������������10
Assigning Variables���������������������������������������������������������������������������������������������10
Using Variables���������������������������������������������������������������������������������������������������10
Integer Types�������������������������������������������������������������������������������������������������������11
Floating-Point Types��������������������������������������������������������������������������������������������11
iii
Table of Contents
Char Type������������������������������������������������������������������������������������������������������������12
Boolean Type�������������������������������������������������������������������������������������������������������12
Variable Scope����������������������������������������������������������������������������������������������������13
Anonymous Block�����������������������������������������������������������������������������������������������13
Type Inference�����������������������������������������������������������������������������������������������������14
Chapter 4: Operators��������������������������������������������������������������������������15
Arithmetic Operators�������������������������������������������������������������������������������������������15
Assignment Operators����������������������������������������������������������������������������������������16
Increment and Decrement Operators������������������������������������������������������������������16
Comparison Operators����������������������������������������������������������������������������������������17
Logical Operators������������������������������������������������������������������������������������������������17
Bitwise Operators�����������������������������������������������������������������������������������������������18
Operator Precedence������������������������������������������������������������������������������������������18
Chapter 5: String��������������������������������������������������������������������������������21
Combining Strings�����������������������������������������������������������������������������������������������21
Escape Characters����������������������������������������������������������������������������������������������22
String Compare���������������������������������������������������������������������������������������������������23
StringBuffer Class�����������������������������������������������������������������������������������������������23
Text Blocks����������������������������������������������������������������������������������������������������������24
Chapter 6: Arrays��������������������������������������������������������������������������������27
Array Declaration������������������������������������������������������������������������������������������������27
Array Allocation���������������������������������������������������������������������������������������������������27
Array Assignment������������������������������������������������������������������������������������������������28
Multidimensional Arrays�������������������������������������������������������������������������������������28
ArrayList Class����������������������������������������������������������������������������������������������������29
iv
Table of Contents
Chapter 7: Conditionals����������������������������������������������������������������������31
If Statement��������������������������������������������������������������������������������������������������������31
Switch Statement�����������������������������������������������������������������������������������������������32
Switch Expression�����������������������������������������������������������������������������������������������33
Ternary Operator�������������������������������������������������������������������������������������������������35
Chapter 8: Loops���������������������������������������������������������������������������������37
While Loop����������������������������������������������������������������������������������������������������������37
Do While Loop�����������������������������������������������������������������������������������������������������38
For Loop��������������������������������������������������������������������������������������������������������������38
For Each Loop�����������������������������������������������������������������������������������������������������39
Break and Continue���������������������������������������������������������������������������������������������39
Labeled Block�����������������������������������������������������������������������������������������������������40
Chapter 9: Methods����������������������������������������������������������������������������41
Defining Methods������������������������������������������������������������������������������������������������41
Calling Methods��������������������������������������������������������������������������������������������������42
Method Parameters��������������������������������������������������������������������������������������������42
Return Statement������������������������������������������������������������������������������������������������43
Method Overloading��������������������������������������������������������������������������������������������44
Passing Arguments���������������������������������������������������������������������������������������������45
v
Table of Contents
Constructor Chaining������������������������������������������������������������������������������������������51
Initial Field Values�����������������������������������������������������������������������������������������������51
Default Constructor���������������������������������������������������������������������������������������������52
Null����������������������������������������������������������������������������������������������������������������������52
Default Values�����������������������������������������������������������������������������������������������������53
Garbage Collector�����������������������������������������������������������������������������������������������53
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
Index�������������������������������������������������������������������������������������������������127
ix
About the Author
Mikael Olsson is a professional web
entrepreneur, programmer, and author. He
works for an R&D company in Finland where
he specializes in software development. In
his spare time, he writes books and creates
websites that summarize various fields of
interest. The books he writes are focused on
teaching their subject in the most efficient way
possible, by explaining only what is relevant
and practical without any unnecessary
repetition or theory.
xi
About the Technical Reviewer
Manuel Jordan Elera is an autodidactic
developer and researcher who enjoys learning
new technologies for his own experiments
and creating new integrations. Manuel won
the Springy Award – Community Champion
and Spring Champion 2013. In his little free
time, he reads the Bible and composes music
on his guitar. Manuel is known as dr_pompeii.
He has tech-reviewed numerous books
for Apress, including Pro Spring MVC with
WebFlux (2020), Pro Spring Boot 2 (2019), Rapid Java Persistence and
Microservices (2019), Java Language Features (2018), Spring Boot 2 Recipes
(2018), and Java APIs, Extensions and Libraries (2018). Read his 13 detailed
tutorials about many Spring technologies, contact him through his blog
at www.manueljordanelera.blogspot.com, and follow him on his Twitter
account, @dr_pompeii.
xiii
Introduction
Java is a high-level object-oriented programming language developed by
Sun Microsystems, which became part of Oracle Corporation in 2010. The
language is very similar to C++ but has been simplified to make it easier
to write bug-free code. Most notably, unlike C++, there are no pointers
in Java—instead, all memory allocation and deallocation is handled
automatically.
Despite simplifications like this, Java has considerably more
functionality than C++, due to its large class library. Java programs
also have high performance and can be made very secure, which
has contributed to making Java the most popular general-purpose
programming language in use today.
Another key feature of Java is that it is platform independent. This is
achieved by only compiling programs halfway, into platform-independent
instructions called bytecode. The bytecode is then interpreted, or run,
by the Java Virtual Machine (JVM). That means any system that has
this program and its accompanying libraries installed can run Java
applications.
To allow Java to be used in a variety of environments, there are four
different editions: Java ME, Java SE, Java EE, and Java FX. Each edition
contains a JVM and a set of class libraries. Java SE (Standard Edition)
provides the standard JVM along with the commonly used libraries for
building applications, in particular desktop applications. Java ME (Micro
Edition) is a small-footprint version of Java SE designed for running on
small devices such as mobile phones. Java EE (Enterprise Edition) is an
extended version of Java SE that includes libraries for building large-scale
xv
Introduction
xvi
CHAPTER 1
Hello World
I nstalling
Before you can program in Java, you need to download and install a Java
Development Kit (JDK), such as the Standard Edition (JDK SE) from
Oracle’s website.1 Among other things, the JDK includes the Java compiler,
the class libraries, and the virtual machine needed to run Java applications.
You should also download an Integrated Development Environment (IDE)
as it will make development in Java much easier. One such Java IDE is
Apache NetBeans,2 which is available for free on Windows, macOS, and
Linux. If you don’t want to use any IDE at all, using a regular text editor is
also an option. To work without an IDE, you can create an empty file with
the .java extension—for example, MyApp.java—and open it in your text
editor of choice.
C
reating a Project
If you decide to use an IDE (recommended), you need to create a
project, which will manage the Java source files and other resources.
To create a project in NetBeans, click File ➤ New Project. In the dialog
1
www.oracle.com/java/technologies/javase-downloads.html
2
https://netbeans.org
Fabu, 67
Fafa, 194, 197, 250, 379
Faguibine, Lake, 33
Faidherbe, General, 17, 24, 352, 500
Fandu, 314, 316
Fanta, 380
Farca, 268, 270, 272, 273
Farimake, 372
Fatimata Azzer’a, 237
Faure, Felix, President, 176
Festing, Major, 474-477, 481, 482, 487, 490
Fily or Fili Kanté, 97, 304, 333, 337, 340, 469, 480
Fituka, 316
Flatters, 114, 145, 244, 391
Flint, Mr., 490
Fogne, 443
Fonssagrives, 458, 474
Footah, 66, 280, 352
Forcades, The, 495
Forcados, 492, 495
Forgo, 164
Fort Archinard, 39, 298, 302, 306, 317, 320-325, 332-337, 339, 344, 348, 356,
360, 371, 387, 392, 398-400, 403, 508
Fort Arenberg or Taubman-Goldie, 470, 471, 473
Fort Goree, 21
Froger, Naval-Ensign, 7
Fulahs or Peuls, the, 3, 65, 75, 78, 129, 166, 181, 194, 202, 251, 271, 280,
309, 312, 314, 316, 325, 351, 352, 359, 362, 363, 368, 379, 386, 394, 396,
408, 422, 436, 454
Futanis, the, 406, 408, 411, 426
Futankés, the, 282, 290, 385, 406
Ha, 163
Habés, the, 367
Habibulaye, 78, 80, 81
Hacquart, Father, 83, 87, 94, 97, 103, 107, 118, 136, 145, 156-158, 172-174,
258, 272, 278, 279, 283, 290, 303, 324, 338, 340, 341, 351, 398, 427, 430,
432, 510
Hadji Hamet, 427, 428, 430, 432, 435
Hamadi, 80, 87, 89
Hamda-Allahi, 76, 78, 314, 365
Hameit, a sheriff, 104, 135, 140
Hamma Tansa, 392
Hanotaux, Commandant, 228
Haussa, 222, 325, 381, 395, 411, 429, 430, 439, 482
Hoggars, the, 81, 114, 136, 144-146, 231, 244-246
Hombori, 367, 373
Hugo, 282-284, 393
M’Pal, 23
Ma, 55, 56
Mabrok, 90
Madani, 292
Madecali, 420, 423-426, 434
Mademba Seye, 66-69, 71, 73
Madidu, Chief of the Awellimiden, 104-107, 136, 154, 155, 164-168, 170-180,
183, 192, 194-196, 217, 219, 240, 247, 265, 266, 271, 277, 286, 312, 368,
372, 382, 387, 426
Madunia, 102, 112
Mage, The, 9, 10, 74
Malet, Sir Edward, 10, 413
Malinke, the, 54
Malo, 277
Mamadu, 97
Mamé, 96, 97, 109, 259, 260, 263, 434
Manambugu, 8, 9, 52
Mandao, Osmane, 17, 26
Marchand, 36, 38
Marka, 274
Massala, 56
Massenya, 1
Massina, 8, 280, 312, 314, 316, 353, 367, 371, 372, 386, 394, 405
Matam, 30
Matar Samba, 87, 95
Mattei, Commandant, 483, 484, 488
Mauri, 313, 377, 413
Maussinissa, 202
Milali, 107
Mizon, 451, 470, 482
Modibo Konna, 394, 396, 397
Mohamed Askia, 165
Mohamed ben Eddain, 208
Mohamed Uld Mbirikat, 118, 121-123, 127, 130, 134, 136, 140
Mohammed ben Abdallah, 88, 201
Mohammed Djebbo, 385
Monteil, Colonel, 6, 7, 11, 17, 285, 360, 412, 413, 421
Mopti, 34, 140, 386, 394, 405
Mores, 474
Morning Star, The, 472
Morocco, 144, 204, 208, 209, 216
Mosi, 216
Mossi, 39, 65, 66, 316, 325, 353, 354, 373, 375, 377-379
Mount Davoust, 440
Mount Delagarde, 440
Mount Kolikoro, 56, 57
Mount Tondibi, 163
Moyadikoira, 147
Mumi, 386, 387
Mungo Park, 5, 6, 9, 165, 439, 500
Mussa, 97, 337
Mycenæ, 118
Taburet, Dr., 38, 52, 58, 60, 87, 94, 97, 118, 123, 134, 135, 158, 277, 278, 281,
290, 303, 327, 328, 332, 333, 338, 348, 393, 416-419, 474, 476, 484, 486,
510
Tacubaos, the, 218
Taddemekka, 182, 207
Tademeket, the, 104, 131, 148, 152, 154-158, 160-162, 168, 170, 201, 241,
269
Tahar, 121, 140
Talibia, 296-298, 360, 379, 381, 387, 388
Ta-Masheg or Tamschek, 109, 173, 202, 220, 222, 226, 228, 229, 509
Tankisso, 404
Tarik, 203
Tarka, 203
Tarkai-Tamut, 203
Tayoro, 394-398
Tchad, Lake, 28, 165, 247, 352, 372, 507
Tchakatchi, 438-440, 499
Tedian Diarra, 358
Tenda, 414-416, 420-424, 430, 447
Tenger Eguedeche, the, 162-164, 168, 170
Tenguereguif, the, 173, 209, 218
Thies, 23
Tieba, 330, 331
Tillé, 389
Timbuktu, 7, 8, 32, 33, 41, 69, 73, 75, 78-84, 87-91, 98, 102, 103, 106, 114-
120, 122, 126, 129, 130, 134, 136, 138, 142, 148, 245, 273, 279, 288, 309,
331, 335, 344, 351, 352, 368, 369, 427, 473, 495, 498, 499, 507
Tinalschiden, 149
Tintellust, 207
Tioko, 372
Togoland, 428
Tolimandio, 52
Tombuttu, 423, 424
Torodi, 312, 313, 315, 382, 384
Toron, 54
Tosaye or Sala Koira, 88, 89, 104, 128, 131, 148-153, 158, 162, 201, 219
Toucouleurs, the, 3, 8, 41, 62, 63, 66, 67, 73, 75, 76, 79, 105, 129, 130, 140,
152, 209, 218, 271, 279-282, 284, 285, 287-290, 299, 304, 312-314, 360,
382, 384, 386-393, 397, 405, 411, 414, 417, 419, 423
Toutée, Captain, 266, 269, 272, 273, 278, 282, 286, 290, 447, 457, 470
Towdeyni, 83
Trentinian, Colonel de, 34, 38, 138
Tripoli, 216, 505
Tuaregs, the, 8, 18, 33, 37, 65, 75, 78-80, 84, 88, 89, 98, 100, 101, 104, 106,
108, 114, 119-134, 138, 142, 144, 149-178, 182, 189-194, 197, 199-249,
251, 256, 257, 266, 269, 270-273, 275, 283, 307, 312, 315, 351, 368, 372,
379, 383, 388, 394, 397, 434, 470, 505-506, 509
Tuat, 78, 79, 81, 88, 216, 310
Tumaré, 268
Ubangi, the, 11
Uro Galadio, 37
Vermesch, 285
Vinet-Laprade, 24
Yakare, 71
Yangbassu, 458
Yauri, 377, 439
Yemen, 78
Yoba, 368
Yola, 479, 482
Yuli, 382
Yunes, 104, 156, 219
Yusuf Osman, 281, 282
FOOTNOTES: