Mastering Java: A Beginner's Guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

<TX1>Mastering Java: A Beginner's Guide introduces developers of all ages to the beautiful and valuable world of Java.

<TX2>Java is frequently used as the default platform for scientific applications, including natural language processing. The primary reason for this is that it is secure, portable, and extensible. It also has excellent high-level concurrency tools.

In terms of software development, the introduction of Java undoubtedly was a watershed moment. You’ve surely heard of Java if you’re a software developer. For a multitude of reasons, its relevance and functionality in the world of coding deserve high acclaim. Computers have become highly adaptable devices that can handle multi-level undo and multi-threaded apps, mostly thanks to Java.

As its syntax is comparable to English, Java is relatively simple to learn and understand in a short period of time. Despite being a slightly older piece of technology, Java still performs well. It is regularly ranked among the most popular languages of programming.

It is critical for enterprise-level web apps and microservices, which are expected to grow in popularity over the coming year. Java will continue to dominate the banking industry and the Fintech business for years to come. Mastering Java addresses various aspects pertaining to Java development.

Mastering Java will prove to be of enormous assistance to Java developers of all levels. This book focuses on a variety of topics; it provides a concise explanation of Java's introduction, benefits, characteristics, and examines why Java is so essential. Mastering Java also includes installation advice and information on the many components that make Java work, such as Object-Oriented Programming, Strings, Collections, Packages, and Databases.

Mastering Java will always be a helpful resource for both intermediate learners and skilled personnel.

Learn more about our other Mastering titles at:

https://www.routledge.com/Mastering-Computer-Science/book-series/MCS

Author(s): Divya Sachdeva, Natalya Ustukpayeva
Series: Mastering Computer Science
Publisher: CRC Press
Year: 2022

Language: English
Pages: 517
City: Boca Raton

Cover
Half Title
Series Page
Title Page
Copyright Page
Contents
About the Editor
CHAPTER 1: Introduction to Java
WHAT IS JAVA?
How Does Java Work?
Why Is Java Important?
Java’s Technical Advantages Include
Java’s Advantages in the Workplace
THE JAVA PROGRAMMING LANGUAGE HAS THE FOLLOWING FEATURES
Simple and Well-Known
Compiled and Interpreted the Data
Independent of the Platform
Portable
Neutral in Architecture
Object-Oriented
Robust
Safe
Distributed
Interactive and Multi-Threaded
Outstanding Performance
Extensible and Dynamic
BASIC SYNTAX
What Is the Syntax of Java?
First Java Program
Syntax for Beginners
Identifiers in Java
Keywords in Java
Modifiers in Java
Variables in Java
Enums in Java
Literals in Java
Comments in Java
Blank Lines
Inheritance
Interfaces
CHAPTER 2: Getting Started with Java
HOW TO SETUP JAVA ON A WINDOWS COMPUTER
In Java, Here’s How to Establish Environment Variables: Classpath and Path
INSTALLING A JAVA INTEGRATED DEVELOPMENT ENVIRONMENT (IDE)
Internal Java Program Details
What Occurs throughout the Compilation Process?
What Occurs When the Program Is Running?
TYPES OF PRIMITIVE DATA
Simple Programs to Write
Identifiers
Variables
Variable Declaration
Assignments Expressions and Assignment Statements
In a Single Step, Declare and Initialize Variables
Constants
Numerical Data Types and Operations
Numerical Operators
Numeric Literals
Integer Literals
Floating-Point Literals
Notations in Scientist
Arithmetic Expressions
Shortcut Operators
Numeric Type Conversions
Character Data Type and Operations
Unicode and ASCII Code
Special Character Escape Sequences
Casting between Char and Numeric Types
String Type
String Concatenation
Converting a String to a Number
String to Integers Conversion
Strings to Doubles Conversion
Using the Console for Input
Using a Scanner to Getting Information
Documentation and Programming Style
Appropriate Comments and Style of Comments
Conventions for Naming
Spacing Lines and Proper Indentation
Block Styles
Errors in Programming
Syntax Problems “Compilation Errors”
Runtime Errors
Logic Errors
Debugging
CONTROL STRUCTURES
If
if Statement
if-else Statement
if-else-if Ladder
Nested if Statement
Switch Statement
Loop Statements
Jump Statements
A GUIDE TO JAVA PACKAGES
Package Kinds in Java
Subpackages in Java
CHAPTER 3: Object-Oriented Programming
JAVA OBJECT-ORIENTED PROGRAMMINGS (OOPs) CONCEPTS
OOPs
Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
Coupling
Cohesion
Association
Aggregation
Composition
In Java, What Is the Difference between an Object and a Class?
Advantages of OOPs over Procedure-Oriented Programming Languages
Java Naming Conventions
Benefits of Java Naming Conventions
Class
Interface
Method
Variable
Package
Constant
Java Objects and Classes
In Java, What Is an Object?
In Java, What Is a Class?
In Java: Instance Variable
In Java: Method
In Java: New Keyword
What Are the Many Methods of Creating an Object in Java?
Anonymous Object
CONSTRUCTORS
Default Constructor
What Is a Default Constructor’s Purpose?
Parameterized Constructor
Why Utilize the Parameterized Constructor?
Constructor Overloading
In Java, What Is the Difference between a Constructor and a Method?
Copy Constructor in Java
Copying Values without Constructor
STATIC KEYWORD
Counter Program with No Static Variables
Counter Program with Static Variables
IN JAVA, “THIS” KEYWORD
JAVA ENUM’S
Inheritance and Enumeration
Methods values(), ordinal(), and function valueOf()
Constructor and Enum
Enumeration and Methods
CHAPTER 4: Creating and Using Java Strims
A BEGINNER’S GUIDE TO STRINGS
Interface for CharSequence
In Java, What Is a String?
What Is the Best Way to Make a String Object?
Methods of the String Class in Java
IMMUTABLE STRING IN JAVA
Why Are String Objects in Java Immutable?
Why Is the String Class in Java Final?
STRING COMPARISON
STRING CONCATENATION
IN JAVA SUBSTRING
METHODS OF JAVA STRING CLASS
Methods toUpperCase() and toLowerCase() in Java String
Method to Java String trim():
The Methods startsWith() and endsWith() in Java String
Method to Java String charAt()
Method to Java String length()
Method to Java String intern()
Method to Java String valueOf()
Method to Java String replace ()
STRINGBUFFER CLASS IN JAVA
StringBuffer Class’s Important Constructors
Mutable String
STRINGBUILDER CLASS IN JAVA
Examples of StringBuilders
DIFFERENCE BETWEEN STRINGBUFFER AND STRING
String and StringBuffer Performance Tests
HashCode Test for Strings and StringBuffers
Difference between StringBuilder and StringBuffer?
Example of StringBuffer
Example of StringBuilder
HOW CAN WE MAKE AN IMMUTABLE CLASS?
The Function toString() Method in Java
Benefit
Java StringTokenizer
StringTokenizer Constructors
StringTokenizer Class Methods
CHAPTER 5: Collections, Lists, and Java’s Built-in APIs
WHAT ARE JAVA ARRAYS?
Advantages
Disadvantages
Array Types in Java
Java Single Dimensional Array
Java Array Declaration, Instantiation, and Initialization
Java Array for Each Loop
Passing an Array to a Method
Method Returning an Array
ArrayIndexOutOfBoundsException
Java Multidimensional Array
Java’s Jagged Array
What Is the Name of the Java Array Class?
Creating a Java Array Copy
In Java, Clone an Array
In Java, Add Two Matrices
In Java, Multiply Two Matrices
JAVA SETS
The Set Interface’s Operations
Methods of Set
LIST IN JAVA
ArrayList vs. Java List
How to Make a List
Converting an Array to a List
How to Convert a List to an Array
Get and Set an Element in a List
Sorting a List
Interface for Java ListIterator
MAP INTERFACE IN JAVA
Hierarchy of Java Map
The interface of Map.Entry
IN JAVA, ITERATING COLLECTIONS
The Four Java Collection Iteration Methods
Method of Java Collection iterator()
CHAPTER 6: Libraries, Packages, and Modules
WHAT IS THE LIBRARY IN JAVA?
Locating a Library
.jar Files Downloading
Documentation in the Library
Classpath
What Exactly Is a Java Class Library?
Library Classes in Java
Making Use of Java Libraries
User vs. Builder
What Is Included in the Java SDK?
WHAT ARE THE PACKAGES IN JAVA?
To Compile a Java Package, Follow These Steps
To Launch a Java Package Application, Follow These Steps
How Do I Go to a Package from Another Package?
JAVA SUBPACKAGE
How Do I Transfer the Class File to a Different Directory or Drive?
Another Approach to Execute this Program Is to Use the Java -Classpath Switch
Methods for Loading Class Files or Jar Files Include
How Do You Combine Two Public Classes into a Single Package?
JAVA ACCESS MODIFIERS
Private Constructor’s Role
Access Modifiers with Method Overriding in Java
ENCAPSULATION
The Benefits of Encapsulation in Java
Class Read-Only
Class Write-Only
CLONING OBJECTS IN JAVA
Why Should You Use the Clone() Method?
The Benefit of Object Cloning
Object Copying Has the Following Disadvantages
MODULES IN JAVA
Benefits of Java Modules
Modular Java Platform for Smaller Application Distribution
Internal Package Encapsulation
Start Detection of Absent Modules
Module Basics in Java
Naming a Java Module
Module’s Root Directory
Module System
Modularized Java 9 JDK
Module for Java 9
Module Name
How to Make a Java Module
Construct a Directory Structure
Source Code for Java
Compile Java Module
Module Execution
WHAT EXACTLY IS MAVEN?
What Does Maven Do?
Maven’s Core Ideas
Maven Installation Procedure
pom.xml Maven File
Elements Utilized in Creating the pom.xml File
Other Pom.xml File Elements
The Benefits and Drawbacks of Using Maven
Benefits
Drawbacks
When Should Maven be Used?
Maven in Practical Application
Maven Repository
WHAT EXACTLY IS GRADLE?
High Performance
The JVM Foundation
Conventions
Flexibility
Gradle: Five Things You Should Know
What Is the Difference between Gradle and Maven?
CHAPTER 7: Java Database Connectivity
WHAT IS JDBC IN JAVA?
What Are the Benefits of Using JDBC?
What Exactly Is API?
DRIVER FOR JDBC
5 Steps to Connecting a Java Database
ORACLE DATABASE CONNECTIVITY IN JAVA
Creating a Table
Example
How to Configure the Temporary Classpath
How to Configure the Permanent Classpath
MySQL Database Connectivity in Java
CONNECTIVITY WITH ACCESS WITHOUT DATA SOURCE NAME (DSN)
Example of Connecting a Java Application without a DSN
Example of Connecting a Java Application to a DSN
DRIVERMANAGER CLASS
Interface of Connection
Statement Interface
DATABASE MANAGEMENT SYSTEM
What Exactly Is a Database?
Database Management System
DBMS Features Include the Usage of a Digital Repository Built on a Server to Store and Manage Information
Benefits of DBMS
DBMS Disadvantages
DATABASE
What Exactly Is Data?
What Exactly Is a Database?
DATABASE EVOLUTION
File-Based
Hierarchical Data Model
Network Data Model
Relational Database
Cloud Database
Benefits of a Cloud Database
NoSQL DATABASE
The Benefit of NoSQL Is Its Scalability
The Disadvantage of NoSQL Is That It Is Open Source
OBJECT-ORIENTED DATABASES
WHAT EXACTLY IS RELATIONAL DATABASE MANAGEMENT?
How Does It Work?
RDBMS History
What Actually Is a Table?
What Exactly Is a Field?
What Is Row or Record?
What Basically Is a Column?
What Is the Distinction between DBMS and RDBMS?
File System vs. DBMS
ARCHITECTURE OF DBMS
DBMS Architecture Types
1st-Tier Architecture
2-Tier Architecture
3-Tier Architecture
The Architecture Consists of Three Schema
MODELS OF DATA
SCHEMA AND INSTANCE OF A DATA MODEL
INDEPENDENCE OF DATA
Language of Database
Database Language Varieties
CHAPTER 8: Java I/O
WHAT IS INPUT/OUTPUT IN JAVA?
Stream
OutputStream versus InputStream
OutputStream
InputStream
Class OutputStream
Class InputStream Class
FileOutputStream Class in Java
Declaration of the FileOutputStream Class
FileInputStream Class in Java
Declaration of the Java FileInputStream Class
BufferedOutputStream Class in Java
BufferedOutputStream Class Example
BufferedInputStream Class in Java
Declaration of the Java BufferedInputStream Class
Constructors of the Java BufferedInputStream Class
SequenceInputStream Class in Java
Declaration of the Java SequenceInputStream class
SequenceInputStream Class Constructors
SequenceInputStream Class Methods
Class Java ByteArrayOutputStream
Declaration of the Java ByteArrayOutputStream Class
Class Java ByteArrayInputStream
Declaration of the Java ByteArrayInputStream Class
DataOutputStream Class in Java
Declaration of the Java DataOutputStream Class
DataInputStream Class in Java
Declaration of the Java DataInputStream Class
FilterOutputStream Class in Java
Declaration of the Java FilterOutputStream Class
FilterInputStream Java Class
Declaration of the Java FilterInputStream Class
Console Class in Java
How to Get the Console Object
FilePermissions Class in Java
Declaration of the Java FilePermission Class
Writer in Java
Reader in Java
FileWriter Class in Java
Declaration of the Java FileWriter Class
FileReader Class in Java
Declaration of the Java FileReader Class
Java’s Properties Class
CHAPTER 9: Java Streams
STREAMING IN JAVA 8
Stream Has the Following Features
STREAM PIPELINE IN JAVA
Methods of the Java Stream Interface
Java Stream Example: Using a Stream to Filter a Collection
Example of Iterating a Java Stream
Filtering and Iterating Collection in a Java Stream Example
Example of a Java Stream: reduce() Method in a Collection
Summation of a Java Stream Example Using Collector Methods
Example of a Java Stream: Determine the Maximum and Minimum Product Price
Example of a Java Stream: count() Method in a Collection
Converting List to Set Using Java Streams Example
Converting a List to a Map Using Java Streams Example
Stream Method Reference
STREAM FILTER IN JAVA
Signature
Parameter
Return
Example of a Java Stream filter()
Example 2 of a Java Stream filter()
BASE64 ENCODE AND DECODE IN JAVA
Encoding and Decoding Fundamentals
Encoding and Decoding of URLs and Filenames
Multipurpose Internet Main Extensions (MIME)
DEFAULT METHODS IN JAVA
Example of a Java Default Method
Java 8 Interface Static Methods
Java 8 Interface vs. Abstract Class
FOREACH LOOP IN JAVA
Method forEachOrdered() in Java Stream
Signature
Java Stream forEachOrdered() Method Example
JAVA COLLECTORS
Example of a Java Collector: Obtaining Data as a List
Example of Using the Sum Function in Java Collectors
Example of Java Collectors: Obtaining Average Product Price
Counting Elements in Java Collectors Example
CHAPTER 10: Functional Programming with Lambda Expressions
WHAT IS FUNCTIONAL PROGRAMMING IN JAVA?
Why Is Functional Programming Important?
Is Java a Good Fit?
JAVA’S PURE FUNCTIONS
LAMBDA EXPRESSIONS IN JAVA
What Is a Functional Interface?
Why Should You Utilize Lambda Expression?
Example of a Java Lambda Expression
APPRAISAL
INDEX