Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Learn Java 12 Programming
Learn Java 12 Programming

Learn Java 12 Programming: A step-by-step guide to learning essential concepts in Java SE 10, 11, and 12

eBook
₹799.99 ₹2323.99
Paperback
₹2904.99
Subscription
Free Trial
Renews at ₹800p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Table of content icon View table of contents Preview book icon Preview Book

Learn Java 12 Programming

Getting Started with Java 12

This chapter is about how to start learning Java 12 and Java in general. We will begin with the basics, first explaining what Java is and its main terms, followed by how to install the necessary tools to write and run (execute) a program. In this respect, Java 12 is not much different to the previous Java versions, so this chapter's content is applies to the older versions too.

We will describe and demonstrate all the necessary steps for building and configuring a Java programming environment. This is the bare minimum that you have to have on the computer in order to start programming. We also describe the basic Java language constructs and illustrate them with examples that can be executed immediately.

The best way to learn a programming language, or any language for that matter, is to use it, and this chapter guides the reader on how they can...

How to install and run Java

When somebody says "Java," they may mean quite different things:

  • Java programming language: A high-level programming language that allows an intent (a program) to be expressed in a human-readable format that can be translated in the binary code executable by a computer
  • Java compiler: A program that can read a text written in the Java programming language and translate it into a bytecode that can be interpreted by Java Virtual Machine (JVM) in the binary code executable by a computer
  • Java Virtual Machine (JVM): A program that reads a compiled Java program and interprets it into the binary code that is executable by a computer
  • Java Development Kit (JDK): The collection of programs (tools and utilities), including Java compiler, JVM, and supporting libraries, which allow the compilation and execution of a program written in the Java language...

How to install and run an IDE

What used to be just a specialized editor that allowed checking the syntax of the written program the same way a Word editor checks the syntax of an English sentence gradually evolved into an Integrated Development Environment (IDE). This bears its main function in the name. It integrates all the tools necessary for writing, compiling, and then executing a program under one Graphical User Interface (GUI). Using the power of Java Compiler, the IDE identifies syntax errors immediately and then helps to improve code quality by providing context-dependent help and suggestions.

Selecting an IDE

There are several IDEs available for a Java programmer, such as NetBeans, Eclipse, IntelliJ IDEA, BlueJ...

Java primitive types and operators

With all the main programming tools in place, we can start talking about Java as a language. The language syntax is defined by Java Language Specification, which you can find on https://docs.oracle.com/javase/specs. Don't hesitate to refer to it every time you need some clarification. It is not as daunting as many people assume.

All the values in Java are divided into two categories: reference types and primitive types. We start with primitive types and operators as the natural entry point to any programming language. In this chapter, we will also discuss one reference type called String (see the String type and literals section).

All primitive types can be divided into two groups: the boolean type and the numeric types.

Boolean type

...

String types and literals

We have just described the primitive value types of the Java language. All the other value types in Java belong to a category of reference types. Each reference type is a more complex construct than just a value. It is described by a class, which serves as a template for creating an object, a memory area that contains the values and methods (the processing code) defined in the class. An object is created by the new operator. We will talk about classes and objects in more detail in Chapter 2, Java Object-Oriented Programming (OOP).

In this chapter, we will talk about one of the reference types called String. It is represented by the java.lang.String class, which belongs, as you can see, to the most foundational package of JDK, java.lang. The reason we introduce the String class that early is that it behaves in some respects very similar to primitive types...

Identifiers and variables

From our school days, we have an intuitive understanding of what a variable is. We think of it as a name that represents a value. We solve problems using such variables as x gallons of water or n miles of a distance, and similar. In Java, the name of a variable is called an identifier and can be constructed by certain rules. Using an identifier, a variable can be declared (defined) and initialized.

Identifier

According to Java Language Specification (https://docs.oracle.com/javase/specs), an identifier (a variable name) can be a sequence of Unicode characters that represent letters, digits 0-9, a dollar sign ($), or an underscore (_).

Other limitations are as follows:

  • The first symbol of an identifier...

Java statements

A Java statement is a minimal construct that can be executed. It describes an action and ends with a semicolon (;). We have seen many statements already. For example, here are three statements:

float f = 23.42f;
String sf = String.valueOf(f);
System.out.println(sf);

The first line is a declaration statement combined with an assignment statement. The second line is also a declaration statement combined with an assignment statement and method invocation statement. The third line is just a method invocation statement.

Here is the list of Java statement types:

  • An empty statement that consists of only one symbol, ; (semicolon)
  • A class or interface declaration statement (we will talk about this in Chapter 2, Java Object-Oriented Programming (OOP))
  • A local variable declaration statement: int x;
  • A synchronized statement: this is beyond the scope of this book
  • An expression...

Summary

This chapter introduced you to the exciting world of Java programming. We started with explaining the main terms, and then explained how to install the necessary tools, JDK and IDE, and how to configure and use them.

With a development environment in place, we provided the reader with the basics of Java as a programming language. We have described Java primitive types, the String type, and their literals. We have also defined what an identifier is, and what a variable is, and finished with a description of the main types of Java statements. All the points of the discussion were illustrated by the specific code examples.

In the next chapter, we are going to talk about the object-oriented aspects of Java. We will introduce the main concepts, explain what a class is, what an interface is, and the relationship between them. The terms overloading, overriding, and hiding will...

Quiz

  1. What does JDK stand for?
    1. Java Document Kronos
    2. June Development Karate
    3. Java Development Kit
    4. Java Developer Kit
  1. What does JCL stand for?
    1. Java Classical Library
    2. Java Class Library
    3. Junior Classical Liberty
    4. Java Class Libras
  1. What does Java SE stand for?
    1. Java Senior Edition
    2. Java Star Edition
    3. Java Structural Elections
    4. Java Standard Edition
  1. What does IDE stand for?
    1. Initial Development Edition
    2. Integrated Development Environment
    3. International Development Edition
    4. Integrated Development Edition
  1. What are Maven's functions?
    1. Project building
    2. Project configuration
    3. Project documentation
    4. Project cancellation
  1. What are Java primitive types?
    1. boolean
    2. numeric
    3. integer
    4. string
  1. What are Java primitive types?
    1. long
    2. bit
    3. short
    4. byte
  1. What is a literal?
    1. A letter-based string
    2. A number-based string
    3. A variable representation
    4. A value representation...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Strengthen your knowledge of important programming concepts and the latest features in Java
  • Explore core programming topics including GUI programming, concurrency, and error handling
  • Learn the idioms and best practices for writing high-quality Java code

Description

Java is one of the preferred languages among developers, used in everything right from smartphones, and game consoles to even supercomputers, and its new features simply add to the richness of the language. This book on Java programming begins by helping you learn how to install the Java Development Kit. You will then focus on understanding object-oriented programming (OOP), with exclusive insights into concepts like abstraction, encapsulation, inheritance, and polymorphism, which will help you when programming for real-world apps. Next, you’ll cover fundamental programming structures of Java such as data structures and algorithms that will serve as the building blocks for your apps. You will also delve into core programming topics that will assist you with error handling, debugging, and testing your apps. As you progress, you’ll move on to advanced topics such as Java libraries, database management, and network programming, which will hone your skills in building professional-grade apps. Further on, you’ll understand how to create a graphic user interface using JavaFX and learn to build scalable apps by taking advantage of reactive and functional programming. By the end of this book, you’ll not only be well versed with Java 10, 11, and 12, but also gain a perspective into the future of this language and software development in general.

Who is this book for?

Students, software developers, or anyone looking to learn new skills or even a language will find this book useful. Although this book is for beginners, professional programmers can benefit from it too. Previous knowledge of Java or any programming language is not required.

What you will learn

  • Learn and apply object-oriented principles
  • Gain insights into data structures and understand how they are used in Java
  • Explore multithreaded, asynchronous, functional, and reactive programming
  • Add a user-friendly graphic interface to your application
  • Find out what streams are and how they can help in data processing
  • Discover the importance of microservices and use them to make your apps robust and scalable
  • Explore Java design patterns and best practices to solve everyday problems
  • Learn techniques and idioms for writing high-quality Java code

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 30, 2019
Length: 690 pages
Edition : 1st
Language : English
ISBN-13 : 9781789958485
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning

Product Details

Publication date : Apr 30, 2019
Length: 690 pages
Edition : 1st
Language : English
ISBN-13 : 9781789958485
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
₹800 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
₹4500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₹400 each
Feature tick icon Exclusive print discounts
₹5000 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₹400 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 10,278.97
Java Coding Problems
₹4096.99
Learn Java 12 Programming
₹2904.99
Hands-On Design Patterns with Java
₹3276.99
Total 10,278.97 Stars icon

Table of Contents

24 Chapters
Section 1: Overview of Java Programming Chevron down icon Chevron up icon
Getting Started with Java 12 Chevron down icon Chevron up icon
Java Object-Oriented Programming (OOP) Chevron down icon Chevron up icon
Java Fundamentals Chevron down icon Chevron up icon
Section 2: Building Blocks of Java Chevron down icon Chevron up icon
Exception Handling Chevron down icon Chevron up icon
Strings, Input/Output, and Files Chevron down icon Chevron up icon
Data Structures, Generics, and Popular Utilities Chevron down icon Chevron up icon
Java Standard and External Libraries Chevron down icon Chevron up icon
Multithreading and Concurrent Processing Chevron down icon Chevron up icon
JVM Structure and Garbage Collection Chevron down icon Chevron up icon
Managing Data in a Database Chevron down icon Chevron up icon
Network Programming Chevron down icon Chevron up icon
Java GUI Programming Chevron down icon Chevron up icon
Section 3: Advanced Java Chevron down icon Chevron up icon
Functional Programming Chevron down icon Chevron up icon
Java Standard Streams Chevron down icon Chevron up icon
Reactive Programming Chevron down icon Chevron up icon
Microservices Chevron down icon Chevron up icon
Java Microbenchmark Harness Chevron down icon Chevron up icon
Best Practices for Writing High-Quality Code Chevron down icon Chevron up icon
Java - Getting New Features Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.7
(6 Ratings)
5 star 33.3%
4 star 33.3%
3 star 0%
2 star 33.3%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Sergio Peris Mar 19, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Este libro es la perfecta guia para aquellas personas que estan aprendiendo Java.Ademas el libro habla muy detalladamente de todas las posibilidades de Java y explica el codigo.Recomiendo este libro para todos los que deseen aprender Java.Ah! Una cosa, el libro esta escrito en ingles.
Amazon Verified review Amazon
Miran Miletic Feb 28, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book love it
Amazon Verified review Amazon
Simone Nov 06, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Sicuramente è un ottimo libro, copre tutto quanto c'è da sapere sulla programmazione java di base. Do base ma non troppo in quanto credo che molte delle cose scritte su questo libro non le sappiano neanche i più senior. Ottimo per dare una bella rinfrescata a quanto studiato ed acquisito con l'esperienza.
Amazon Verified review Amazon
Ramona Dec 23, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Acquistato per mio marito, che è autodidatta. Finora è contento della qualità del prodotto a livello complessità e accessibilità.
Amazon Verified review Amazon
Pedro Mar 14, 2021
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This book is not to grab it and start coding JAVA... This book is an absolute reference guide and nothing else. If you want to get your hands dirty with code, this book is not for you. If you want to review JAVA concepts and see SNIPPETS, yes, SNIPPETS with minimal effort of separating them and preparing the reader to see code, then... go for it. I give it a 2 because I have to admit it has good points on theory, but in code, na-ah. My suggestion, get another book to learn to code...
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.