Introduction to Programming
eBook - ePub

Introduction to Programming

Learn to program in Java with data structures, algorithms, and logic

Nick Samoylov

Share book
  1. 722 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Introduction to Programming

Learn to program in Java with data structures, algorithms, and logic

Nick Samoylov

Book details
Book preview
Table of contents
Citations

About This Book

Get a solid understanding of Java fundamentals to master programming through a series of practical steps

Key Features

  • Enjoy your first step into the world of programming
  • Understand what a language is and use its features to build applications
  • Learn about a wide variety of programming applications

Book Description

Have you ever thought about making your computer do what you want it to do? Do you want to learn to program, but just don't know where to start? Instead of guiding you in the right direction, have other learning resources got you confused with over-explanations?

Don't worry. Look no further. Introduction to Programming is here to help.

Written by an industry expert who understands the challenges faced by those from a non-programming background, this book takes a gentle, hand-holding approach to introducing you to the world of programming. Beginning with an introduction to what programming is, you'll go on to learn about languages, their syntax, and development environments. With plenty of examples for you to code alongside reading, the book's practical approach will help you to grasp everything it has to offer. More importantly, you'll understand several aspects of application development. As a result, you'll have your very own application running by the end of the book. To help you comprehensively understand Java programming, there are exercises at the end of each chapter to keep things interesting and encourage you to add your own personal touch to the code and, ultimately, your application.

What you will learn

  • Understand what Java is
  • Install Java and learn how to run it
  • Write and execute a Java program
  • Write and execute the test for your program
  • Install components and confgure your development environment
  • Learn and use Java language fundamentals
  • Learn object-oriented design principles
  • Master the frequently used Java constructs

Who this book is for

Introduction to Programming is for anybody who wants to learn programming. All you'll need is a computer, internet connection, and a cup of coffee.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Introduction to Programming an online PDF/ePUB?
Yes, you can access Introduction to Programming by Nick Samoylov in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Java. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781788834162
Edition
1

Interfaces, Classes, and Object Construction

This chapter explains to readers the most important aspects of Java programming: Application Programming Interfaces (APIs), object factories, method overriding, hiding, and overloading. An explanation of the design advantage of aggregation (versus inheritance) follows, starting the discussion around software system design. The chapter concludes with an overview of Java data structures.
In this chapter, we will cover the following topics:
  • What is an API?
  • Interface and object factory as APIs
  • Overriding, hiding, and overloading
  • The this and super keywords
  • Constructors and constructor overloading
  • Final variable, final method, and final class
  • Object association (aggregation)
  • Exercise – Restricting a class instantiation to a single shared instance

What is an API?

The term Application Programming Interface (API) is a specification of protocols, procedures, and services that can be used as building blocks by a programmer to implement a required functionality. An API may represent a web-based system, operating system, database system, computer hardware, or software library.
In addition to that, in everyday life, the term API is often applied to the system that implements the specification. For example, you might be familiar with Twitter APIs (https://developer.twitter.com/en/docs) or Amazon APIs (https://developer.amazon.com/services-and-apis), or you might have worked with devices (sensors) that are able to respond to a request by providing the data (measurement results). So, when programmers say we can use an Amazon API, they mean not only the description of the provided procedures, but the services themselves.
In Java, we have also a few variations of the term API usage that we would like to identify and describe in the following subsections.

Java APIs

Java APIs include two big groups of APIs and libraries that implement them:
  • Java core packages (http://www.oracle.com/technetwork/java/api-141528.html) that come with the Java installation and are included in the JDK
  • Other frameworks and libraries that can be downloaded separately, such as Apache Commons APIs (https://commons.apache.org), for example, or the three libraries we have already included as dependencies in the Maven pom.xml file of our demo project. The vast majority of them can be found in the Maven repository (https://mvnrepository.com), but a variety of new and experimental libraries and frameworks can be found eslewhere.

Command line APIs

A command line API describes the command format and its possible options that can be used to execute the application (tool). We have seen such examples when we talked about using the tools (applications) java and javac in Chapter 1, Java Virtual Machine (JVM) on Your Computer. We even built our own application in Chapter 4, Your First Java Project, defined its API, and described its command line API as accepting an integer as a parameter.

HTTP-based APIs

A web-based application often provides an HTTP-based API using a variety of protocols (https://en.wikipedia.org/wiki/List_of_web_service_protocols) that allow access to the application functionality via the internet. HTTP stands for Hypertext Transfer Protocol, which is an application protocol for distributed information systems that serves as the foundation of data communication for the World Wide Web (WWW).
The two most popular web service protocols are:
  • XML-based SOAP (Simple Object Access Protocol) protocol
  • JSON-based REST or RESTful (REpresentational State Transfer) style over HTTP protocol
Both describe how functionality (services) can be accessed and incorporated into the application. We do not describe web services in this book.

Software component API

A software component may be a library, an application subsystem, an application layer, or even a single class--something that can be used directly from Java code by invoking its methods. An API of a software component looks like an interface that describes method signatures which can be invoked on the objects of classes that implement the interface. If the component has public static methods (which do not require objects and can be invoked using classes only), these methods have to be included in the API description as well. But for a complete description of the component API, as we have mentioned already in Chapter 2, Java Language Basics, the information about how the objects of the component can be created should be part of the API description, too.
In this book, we are not going beyond application boundaries and will use the term API only in the sense of a software component API, as described previously. And, we will call the entities that implement an API (the services that the API describes) by their names: application subsystem, application l...

Table of contents