Essential Java for AP CompSci: From Programming to Computer Science 1st Edition Doug Winnie - Download the ebook and explore the most detailed content
Essential Java for AP CompSci: From Programming to Computer Science 1st Edition Doug Winnie - Download the ebook and explore the most detailed content
com
https://ebookmeta.com/product/essential-java-for-ap-compsci-
from-programming-to-computer-science-1st-edition-doug-
winnie/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookmeta.com/product/essential-java-for-ap-compsci-from-
programming-to-computer-science-1st-edition-doug-winnie/
ebookmeta.com
https://ebookmeta.com/product/java-all-in-one-for-dummies-fifth-
edition-doug-lowe-3/
ebookmeta.com
https://ebookmeta.com/product/soccer-and-the-american-dream-1st-
edition-ian-lawrence/
ebookmeta.com
Boundaries of a Complex World 2nd Edition Andrei Ludu
https://ebookmeta.com/product/boundaries-of-a-complex-world-2nd-
edition-andrei-ludu/
ebookmeta.com
https://ebookmeta.com/product/mixed-messages-american-correspondences-
in-visual-and-verbal-practices-1st-edition-catherine-gander/
ebookmeta.com
https://ebookmeta.com/product/the-exhibitionist-1st-edition-charlotte-
mendelson/
ebookmeta.com
The Pope s Army The Papacy in Diplomacy and War Car John
https://ebookmeta.com/product/the-pope-s-army-the-papacy-in-diplomacy-
and-war-car-john/
ebookmeta.com
https://ebookmeta.com/product/his-for-the-summer-mountain-ridge-
resort-1st-edition-sammi-starlight/
ebookmeta.com
Doug Winnie
Trademarked names, logos, and images may appear in this book. Rather
than use a trademark symbol with every occurrence of a trademarked
name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark. The use in this publication
of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of
opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true
and accurate at the date of publication, neither the authors nor the
editors nor the publisher can accept any legal responsibility for any
errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained
herein.
This Apress imprint is published by the registered company APress
Media, LLC part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
For Mike, and all of the great decisions we have made together.
Table of Contents
Sprint 1:Introduction
What You Need
Sprint 2:Setting Up the Java JDK and IntelliJ
Coding Tools and IDEs
Installation and Setup
Install the JDK
Install IntelliJ
Sprint 3:Setting Up GitHub
GitHub
How GitHub Works
Lifecycle of a Repository
Sprint 4:Programming Languages
Origin of Programming
Forms of Programming
Machine Language
Interpreted
Compiled
Object-Oriented
Data
Functional
Scripting
Sprint 5:History and Uses of Java
Java Beginnings
Java’s Primary Goals
Uses of Java
Sprint 6:How Java Works
The Problem with Compiled Languages
The JVM and JRE
Compiling Java Bytecode
Precompiled Files
OpenJRE
Sprint 7:Flowcharting
Flowcharting Tools
Paper
Tablet and Stylus
Apps
Flowcharting Basics
Terminus
Process/Action
Input and Output
Decisions
Annotations
Other Shapes
Take Out the Trash
But Is It Really That Simple?
Sprint 8:Hello, World
Create Your IntelliJ Java Project
IntelliJ IDEA
First Time Only:Configure the JDK
Create Project
About Your Project
Coding Your Project
Writing Your First Program
Create Your Repo in GitHub
Upload Your Code to GitHub
Sharing Program Output
Sprint 9:Simple Java Program Structure
Sprint 10:Text Literals and Output
Text Output
Escape Sequences
Sprint 11:Value Literals
Literal Formatting
Sprint 12:Output Formatting
Decimal Formatters
Thousands Formatters
Currency Formatters
Spacing and Alignment Formatters
Multiple Items in Formatters
Sprint 13:Comments and Whitespace
Sprint 14:Abstraction of Numbers
Sprint 15:Binary
Binary Numbers
Bit Size and Values
Overflow
Sprint 16:Unicode
Text Encoding
ASCII + Unicode
Emoji
Sprint 17:Variables
Essentials of Variables
Code Examples
Sprint 18:Math!
Basic Operators
Order of Operations
String Concatenation
Code Examples
Sprint 19:Math Methods
Working with Simple Methods
Multiparameter Methods
Illegal Value Types in Methods
Math Constants
Code Examples
Sprint 20:Managing Type
Mixing Types in Evaluations
Numbers to Strings
Strings to Numbers
Casts
Cast Errors
Code Examples
Sprint 21:Random Numbers
Create a Random Number Generator
Random Integers
Random Decimals
Code Examples
Sprint 22:Capture Input
Hello, Scanner
Capturing Strings
Capturing Integers
Capturing Decimals
Code Examples
Sprint 23:Creating Trace Tables
It’s a Spreadsheet
Um.Why?
Sprint 24:Methods
Method Basics
Writing a Method
Call a Method
Method Flow
Code Guide
Code Examples
Sprint 25:Calling Methods Within Methods
Methods Within Methods
Infinite Methods
Code Examples
Sprint 26:Methods and Values
Accepting Values in Methods
Returning a Value
Overloading a Method
Code Guides
Code Examples
Sprint 27:Methods and Scope
Variable Scope Errors
Defining Class-Scoped Variables
Class Conflicts
Code Examples
Sprint 28:Boolean Values and Equality
Creating a Boolean Variable
Boolean Logic Operators
Altering a Boolean Value
Combining Logic with Evaluations
Compound Logic Operators
Code Examples
Sprint 29:Simple Conditional Statements
The if Statement
The else Statement
The else if Statement
Understanding Conditional Flow
Code Examples
Sprint 30:Matching Conditions with the switch Statement
Creating a switch Statement Code Block
Things to Look Out for with the switch Statement
Code Examples
Sprint 31:The Ternary Operator
The if-else Statement Equivalent
Converting to a Ternary Operator
Using the Ternary Operator Inline with Code
Code Examples
Sprint 32:The Stack and the Heap
Understanding the Stack
Understanding the Heap
Why This All Matters
Sprint 33:Testing Equality with Strings
When the Heap Throws Equality
How to Better Compare String Values
Code Examples
Sprint 34:Dealing with Errors
Coding to Catch Errors
“Catching” Specific Errors
Code Examples
Sprint 35:Documenting with JavaDoc
Using JavaDoc Syntax
Generating Documentation
Code Examples
Sprint 36:Formatted Strings
Creating a Formatted String Literal
Code Examples
Sprint 37:The while Loop
Create a while Loop
Code Examples
Sprint 38:Automatic Program Loops
Creating a Program Loop
Code Examples
Sprint 39:The do/while Loop
Creating a do…while Loop
Run at Least Once
Sprint 40:Simplified Assignment Operators
Combined Assignment
Increment and Decrement
Placement and Program Flow
Code Examples
Sprint 41:The for Loop
Creating a for Loop
Changing the Step
Code Examples
Sprint 42:Nesting Loops
Creating Nested Loops
Displaying as a Grid
Code Examples
Sprint 43:Strings as Collections
Creating Strings Using the String Class
Getting a String Length
Getting a Specific Character from a String
Finding a Character in a String
Extracting a Substring
Comparing Strings
Code Examples
Sprint 44:Make Collections Using Arrays
Creating an Array with Values
Getting a Value from an Array
Creating an Array by Size
Things to Avoid with Arrays
Getting the Number of Values in an Array
Looping Through an Array
Code Examples
Sprint 45:Creating Arrays from Strings
Delimited Strings
Splitting It Up
What About Numbers?
Code Examples
Sprint 46:MultidimensionalArrays
Define a MultidimensionalArray
Assign Values to MultidimensionalArrays
Access Values in MultidimensionalArrays
Rectangular and Irregular Arrays
Code Examples
Sprint 47:Looping Through MultidimensionalArrays
Creating Nested Loops for Arrays
Code Examples
Sprint 48:Beyond Arrays with ArrayLists
Create an ArrayList
Add Items to ArrayLists
Get Elements in ArrayLists
Remove Elements from ArrayLists
Find Items in ArrayLists
Replace Items in ArrayLists
Get the Size of an ArrayList
Copy Elements to a New ArrayList
Clear an ArrayList
Code Examples
Sprint 49:Introducing Generics
Create an ArrayList with Generics
Typing Using Generics
Code Examples
Sprint 50:Looping with ArrayLists
Working with size( ) and get( ) Methods
Code Examples
Sprint 51:Using for…each Loops
Mechanics of a for…each Loop
This Is the Mechanics of the for…each Loop
ArrayLists Without Generics
Yep, Arrays Work Too
Code Examples
Sprint 52:The Role-Playing Game Character
What Is a Role-Playing Game Character?
Filling Out Our Character Sheet with Data
Classes, Instantiation, and Construction
Player Character Sheets
Fighter
Mage
Paladin
Priest
Sprint 53:Polymorphism
Creating a Class Hierarchy
Party Up—All the Same—but All Different at the Same Time
The Essential Tool:The Die
Class Hierarchy, Polymorphism, Abstract, and Static
Sprint 54:Make All the Things…Classes
Creating Some Class
Instantiate Thyself, Class!
Sprint 55:Class, Extend Thyself!
Sprint 56:I Don’t Collect Those; Too Abstract
Sprint 57:Access Denied:Protected and Private
Sprint 58:Interfacing with Interfaces
Sprint 59:All I’m Getting Is Static
Sprint 60:An All-Star Cast, Featuring Null
Index
About the Author
Doug Winnie
has been teaching programming in the
classroom or with online videos for over
15 years. Online, his videos have over
two million views on Adobe, Lynda.com,
and LinkedIn Learning. Doug’s courses
cover topics like computer science
principles, Java, C#, JavaScript, product
management fundamentals, virtual
machines, and other products and
technologies.
He has written two books on
programming and collaboration between
user experience designers and
developers.
Currently, he is the Chief Learning
Officer at MentorNations, an
international nonprofit focused on
evolving digital literacy and entrepreneurial skills across the world.
Previously, Doug was head of community for the LinkedIn Learning
instructor organization, representing the interests of over 1400
teachers and instructors worldwide. He was an internal contributor to
the Windows Insider Program and part of a global initiative at
Microsoft to teach 7.6 billion people around the world digital coding
and programming literacy skills. He was also a LinkedIn Culture
Champion, working with LinkedIn employees around the globe to put
on employee cultual events on special days called InDays.
Earlier, Doug was a principal product manager at Adobe and
specialized working on new products for the user experience,
interactive design, and web design audiences.
You can find out more about Doug on his LinkedIn profile:
www.linkedin.com/in/sfdesigner
About the Technical Reviewer
Jeff Friesen
is a freelance teacher and software developer with an emphasis on Java.
In addition to authoring Java I/O, NIO and NIO.2 (Apress) and Java
Threads and the Concurrency Utilities (Apress), Jeff has written
numerous articles on Java and other technologies (such as Android) for
JavaWorld (JavaWorld.com), InformIT (InformIT.com),
Java.net, SitePoint (SitePoint.com), and other websites. Jeff can
be contacted via his website at JavaJeff.ca or via his LinkedIn
profile (www.linkedin.com/in/javajeff).
© Doug Winnie 2021
D. Winnie, Essential Java for AP CompSci
https://doi.org/10.1007/978-1-4842-6183-5_1
1. Introduction
Doug Winnie1
(1) Mission Hills, KS, USA
Computer science has become a basic life skill that everyone is going to
need to learn. Whether you are going into a career or side hustle in
business, technology, creativity, architecture, or almost any other field,
you will find programming, coding, and computer science play a role.
In fact, if you look at the top skills on LinkedIn for the United States,
in the last year all ten of the top were programming, computer science,
or code related. These include cloud and distributed computing,
statistical analysis, data mining, mobile development, storage systems
management, user interface design, network and information security,
middleware and integration software, web architecture and
development frameworks, algorithm design, and Java development.1
What is unique about computer science is how it has become a skill,
and not just a career. While there are jobs and titles of “Computer
Scientist,” the skill of computer science, and specifically coding and
programming, is almost everywhere.
In marketing, you need to analyze and sift through tons of user data
and metrics on how people use your products, website, apps, or
services. In medicine, doctors and researchers need to gather and
analyze data gathered from clinical studies or to find new
breakthroughs. In agriculture and farming, thousands of IoT devices
need to be deployed and managed to gather data on soil conditions,
humidity, and crop health. In architecture and construction, mapping
out and analyzing how people use elevators, building infrastructure, or
public spaces can help design better buildings for people to work and
live in. Even when building a side business, or “hustle,” entrepreneurs
may need to perform research, build a website, program a mobile app
or game, or perform tons of different activities involving code, logic,
automation, and programming.
When people create projects based on code, they organize their
work into multiple chunks or segments of development. They call these
“sprints.” So, we will learn Java in the same way, using multiple sprints
that will teach a single topic to help us keep pace with things along the
way. Part of what makes learning coding difficult is it can be difficult to
find real-world examples to draw parallels from. If you are planning on
taking the AP Exam in Computer Science, many of the questions will not
have any real-world context and will require you to understand and
follow code without that as a reference.
For you, this can make it confusing, but just remember: there are
two sides to programming—what is being done and how it happens.
The “what” is pretty easy, and this gives the code context, like
parsing transit data, rolling a virtual die, or adding sales data for a
quarter together.
“How” it happens is a completely different story however. This is
where you need to break things down into individual steps and start to
think like a computer. A computer is going to think only about one
single step at a time. It has no concept of what comes next or what
came before it. It only is concerned with the present. So, if it can’t find
something—you get an error. If it tries to do something that doesn’t
exist—you get an error. If you try doing something out of order—you
guessed it, you get an error.
In fact, the computer is pretty dumb. I mean, like really dumb. What
makes it smart is how we are able to string multiple actions together to
make something work. And with growing advances in artificial
intelligence, the computer itself can start making adjustments. And
then Skynet activates, and we all know what happens after that.
So when we learn programming, we are going to focus on three
things:
What is the process
What is the syntax
What is the flow
The process is represented as a flowchart. We will learn how to
make these to help you plan out what you are going to do before you
write a line of code. At first, the flowcharts will be pretty simple, but
then they will get more complex. And yep, you will get pretty annoyed
with flowcharts before the year is over, but trust me…they help.
The syntax is the code; this is what you write that translates the
process you create in a flowchart to the instructions that the computer
can understand.
Finally, there is the flow. This is where you trace through the code
and see how the data and information it stores along the way changes,
and you can see how the operation of the program cascades from line to
line. You will be building charts that will capture the programming flow
so you can better understand how the computer processes code to
make your next program easier to conceive and code.
Footnotes
1 “The Top 10 Skills You Will Be Hiring For in 2017,”
https://business.linkedin.com/talent-solutions/blog/trends-
and-research/2016/linkedin-new-report-reveals-the-latest-job-
seeking-trends
© Doug Winnie 2021
D. Winnie, Essential Java for AP CompSci
https://doi.org/10.1007/978-1-4842-6183-5_2
To get started with our exercises, we need to set up our computers to work with
Java code and run it. This is called creating a development environment.
As you learn more about coding and programming, you will encounter many
different tools to help you do your job. There are so many in fact, that you might
find that one fits better than another. While they all essentially do the same thing,
there are features and options in different tools that mesh better with different
types of coders.
www.oracle.com/technetwork/java/javase/downloads/index.html
Install IntelliJ
Now we need to install IntelliJ IDEA.
With your browser, go to the JetBrains website:
www.jetbrains.com
Under Tools, look for the column IDEs, and select IntelliJ IDEA. We will use the
Community Edition, which is free.
Your browser will prompt you to save the installer to your computer. Click Save
to continue and download.
Run the installer and accept the defaults for all the settings.
That’s it! IntelliJ IDEA and the Java Development Kit are successfully installed!
© Doug Winnie 2021
D. Winnie, Essential Java for AP CompSci
https://doi.org/10.1007/978-1-4842-6183-5_3
3. Setting Up GitHub
Doug Winnie1
(1) Mission Hills, KS, USA
When you code, you need to have a location to store it and share that
code with others to work with it and review it. Tools called code
repositories are ideal ways to do this, and there are several different
types that are available for developers to use; one of the most popular
is GitHub, and we will explore it here. GitHub, in the context of this
book, is a tool that you can use on your own. I’m introducing it here,
because as you get more familiar with programming, you’ll find it to be
an indispensable tool.
Figure 3-1 Repository lifecycle
GitHub
The one that we will use is called GitHub. GitHub is a free public code
platform that developers use to build, archive, and manage coding
projects for individual or group collaboration. It is built on the Git
technology that is ordinarily used for private, internal projects, but
GitHub builds their public platform on Git to make it available to
anyone.
To create a GitHub account is simple. Go to www.github.com/
and create an account there. For our use in class, please create your
account as your Serra email address so I can easily identify your
account.
When you create your account, be sure to go to GitHub Desktop to
download the desktop client for Windows or macOS. You can download
the installer here: https://desktop.github.com/.
Install the client and sign in to your account. You can then create a
repository to keep track of the changes you make in your classwork
projects. You can create a single project to capture all of your
homework assignments, or you can create an individual repository for
each project. Whichever you choose is up to you.
Lifecycle of a Repository
A repository, or repo, starts with the master branch, sometimes known
as a trunk. For individual developers, or small teams, projects might
only use a master branch and never create alternate versions of it.
As the program evolves and new changes are made, they are saved
to the repository by making a commit. A commit contains the changes
to the code and a brief comment and description made by the
developer on what changed for future reference. Over time, there will
be dozens or hundreds of commits on a repository.
At some point, a repository will need to split in some way. Either
there needs to be simultaneous work and they don’t want to have code
conflict with others, or a project needs to maintain an existing version
and they want to do something else with it. In that case, a branch is
created from the main trunk, and development can happen in parallel
with the original code.
At some point, a branch will need to rejoin the main development,
and this is done by merging that branch back into the master trunk.
For open source repositories, it is common for a developer to find a
helpful framework and want to add it to their own development
environment. To do that, they would fork the repository, creating a copy
in their own environment to work with and potentially make changes.
When a developer makes changes or improvements to a forked
repository, they might want to contribute those changes back to the
main repository they forked from. To do that, they submit a pull request
back to the original repository. As part of this pull request, the
developer outlines the changes that were made, and the person who
receives the requests can compare the proposed changes to the repo by
performing a diff that shows the changes side by side from one another.
Repositories can vary in complexity from something very simple
with a single or a handful of developers to a large open source project
with tens of thousands of developers. Code repos are the core of how
software developers work together on projects of any size.
© Doug Winnie 2021
D. Winnie, Essential Java for AP CompSci
https://doi.org/10.1007/978-1-4842-6183-5_4
4. Programming Languages
Doug Winnie1
(1) Mission Hills, KS, USA
Origin of Programming
In the early 1840s, Charles Babbage proposed a machine called the
Analytical Engine. It was only a proposal—no actual machine was built,
but one inventive woman by the name of Ada Lovelace decided to write
an article that provided detailed instructions on how to represent
Bernoulli [ber-noo-li] numbers, a recursive equation based on number
theory, on the Analytical Engine. This article is considered to be the
very first computer program.
Since then the devices that can be programmed went from
theoretical to physical, manual to automatic, analog to digital. With
each evolutionary step, the way we program computers needed to
evolve as well.
With the birth of mainframe computers, data processing required
instructions to be sent to the machine to process and interpret the
instructions from the programmer. This was then applied to data to
organize and analyze the data. Instructions were entered through a
keyboard, but without the benefit of a monitor, so everything was done
through printouts on paper or storing data in the form of punched
holes on cards that were stored in stacks. If you look carefully at text
encodings and at some programming languages, you’ll see things like
“carriage return” or “print” that are carryovers from those printer days
from decades ago.
As computers got smaller and more powerful, more languages were
created. Languages also were created to serve specific types of projects
and industries like mathematics and science, data storage, and
graphics.
Today, we work with programming languages that can serve many
different purposes. In fact, a programmer often needs to use multiple
programming languages to get a project completed. As languages have
evolved, they have become specialized to complete specific tasks. As a
programmer, you will use the best languages for specific tasks and
combine them together to create your project.
The programming languages you learn today will continue to evolve
and change in the future. With future waves of new technology, new
languages will be developed to allow programmers to drive even more
innovation.
Forms of Programming
As programming has evolved over the decades, the types of
programming you can do have changed as well. Depending on what you
want to do, there are different types or forms of programming
languages that work in different ways. As a programmer, some forms of
programming give you direct access to the computer processor, while
others abstract the hardware into more human language that needs to
be translated or converted into the native language of the hardware.
Here are some example forms of programming that you might
encounter.
Machine Language
Machine languages allow programmers to code instructions directly to
the processor or hardware. Processors can be programmed by sending
sequences and patterns of ones and zeros through the processor to
enable actions to take place. As a result, the code that is entered by the
programmer is almost natively written. Assembly language, which is an
abstraction of machine language, uses special codes to modify
processor registers and perform functions.
Interpreted
Interpreted languages are readable by humans more easily than
assembly or machine languages. The programmer writes the code and
then runs it. A component called an interpreter reads each line of code
and then “interprets” it into native instructions for the computer. The
process is much slower than machine language since the interpreter
needs to convert each instruction provided by the programmer, even if
it repeats a line of code multiple times—it needs to interpret it each
time. JavaScript is an example of an interpreted language. A
programmer can stop the execution of the program, make a change to a
line, and then run it again without any other steps.
Compiled
A compiled language takes instructions written by a human and sends
that code to something called a compiler. A compiler takes the program
instructions and converts it to binary bytecode or native code for the
hardware and creates a program called an executable. This program is
native to the hardware and operating system and can’t easily be
converted back to the original programmed instructions. With the code
now in the native computer format, it runs much faster than
interpreted code, but if you need to make a change, you need to adjust
the original program instructions and recompile it to create a new
executable. If you are creating programs for multiple types of
processors, you need to compile unique versions for each native
instruction code for the target platforms. C is an example of a compiled
language.
Object-Oriented
Object-oriented programming, or OOP, treats everything as an object.
An object can store values; perform actions, called methods; and accept
and return values. An object is defined using a template, called a class,
that defines what an object can do. A programmer can then create an
instance of that class that has all of the capabilities defined by the class.
Java and C# are examples of object-oriented languages.
Data
There are languages that are specifically designed at working with data.
One example is SQL, pronounced as see-quel, which is a language
designed for working with databases. This is a query language, where
you ask a database a question and it gives you a set of data as a result.
You can use SQL to combine multiple databases together to create
combinations that you can then analyze. R is another example of a data
language. R is designed for statistical computing and graphing.
Functional
Functional programming approaches programming in a much different
way. Think of it like this: In a traditional programming language, which
is called imperative, you are defining the state of a value, object, or
component. You create and define tasks to complete, called an
algorithm, that go from beginning to end. Functional programming isn’t
bound by an algorithm. In a functional language, you perform
transformations on values, like a function in mathematics. You take a
value or object and modify it, with the ability to string multiple
transformations together using functions. Functional languages focus
on what needs to be done, without much care for how it is performed.
Examples of functional languages include Haskell, Scala, and F#.
Scripting
Operating systems regularly need to execute commands to configure
servers, install software, or perform maintenance. To automate that
process, there are scripting languages that allow systems like Windows,
Linux, and macOS to save common commands as a script that can be
run multiple times or distributed to multiple computers. PowerShell,
perl, and bash are examples of scripting languages .
As you can see, there are multiple types of programming languages
that you can work with to perform different types of tasks. This course
will focus on concepts found in object-oriented, compiled, and
interpreted languages like JavaScript, Java, C#, and Swift.
© Doug Winnie 2021
D. Winnie, Essential Java for AP CompSci
https://doi.org/10.1007/978-1-4842-6183-5_5
Java started off with lofty goals, and today it is one of the most popular
and widely used languages throughout the world.
Java Beginnings
Java got its start at Sun Microsystems and was first released to the
public in 1995. The development of the language started in 1991 by
James Gosling, Mike Sheridan, and Patrick Naughton and was designed
to be similar to C and C++ to help developers use their existing
programming skills for the new language. Sun Microsystems was
acquired by Oracle in 2009.
During development, Java was originally called Oak, then renamed
Green, and finally released as Java from Java coffee, which is why the
logo for Java is of a steaming coffee cup.
Today, Java is one of the most popular languages in use. Java’s heavy
use in web applications, enterprise desktop applications with
technologies like JavaFX, and the Android ecosystem makes it a great
language to learn with many flexible ways to use it.
Uses of Java
Since Java was first released, it has grown to power many large-scale
web applications for ecommerce, finance, and other industries. Java
applications are built on the server side and connect to web servers to
handle the business logic of applications.
Java is also the core language of Android, and native applications
created using Google’s Android Studio tools are built using the Java
language. In addition, you’ll find Java embedded in many devices, like
televisions and other consumer electronics.
Many frameworks have been created based on the Java
programming language to accelerate the development of applications
across many platforms and devices.
For web applications, frameworks like Struts, JSF, Grails, Spring, and
others are used individually or in combination with each other to
provide scalable web apps that can support millions of customers.
For desktop applications, frameworks like JavaFX allow developers
to create user interfaces using FXML, an XML-based markup language,
and meld that with Java code.
For mobile, the Android SDK from Google contains a tool for
developing Android apps and an emulator to deploy and run your app
on a virtual device for testing.
As a developer, there are many coding tools available to you for Java.
Integrated development environments, or IDEs, help combine many of
the tasks you need to perform like coding, code management,
debugging, working with code repositories, and creating
documentation. Some of the more popular IDEs are IntelliJ IDEA,
Eclipse, and NetBeans. The one we will be using in this course is from
IntelliJ.
Java opens up almost unlimited opportunities for you as a
developer, and the best thing is that Java is not complicated to learn or
understand once you get past the basics. Using your new Java skills, you
can build apps for almost anything.
© Doug Winnie 2021
D. Winnie, Essential Java for AP CompSci
https://doi.org/10.1007/978-1-4842-6183-5_6
Precompiled Files
Sometimes, you will want to have files that you use repeatedly in your
program. These generally are sections of code that will never change
but contain prebuilt actions that you can execute and use in your own
custom code.
Maintaining these files can be extensive, and when you make
improvements to this code, you want to find a way to make it easy to
take those improvements and bring them to other programs.
To make this easier, Java supports combining precompiled code into
.jar files. JAR, or Java Archive, is a single module that you can then bring
into any program and access the actions and methods within it just as if
they were part of your code.
If you ever want to update or change the JAR, you can just change
that single reference or overwrite the JAR file that your program points
to and the updates are made.
OpenJRE
Java is an open source language , meaning that the community can
build, change, and improve the language and the compiler.
As part of this, Oracle has created the OpenJRE and OpenJDK for the
community to build and enhance. Oracle can then take contributions
made by the open source community and bring them into the official
Oracle Java JDK and JRE.
Oracle then adds additional security and other protections to
ensure the applications that run on it are safe and secure. Because it is a
packaged platform, this security is applied to any hardware, server, or
cloud infrastructures.
Android is largely built on Java, and starting with Android N, or
Android Nougat, Google switched to the OpenJDK due to litigation with
Oracle.
In the end, to you, it doesn’t matter which version of Java you are
running. When you install any JDK and JRE, the source code, compiled
files, and execution of the programs are essentially the same.
© Doug Winnie 2021
D. Winnie, Essential Java for AP CompSci
https://doi.org/10.1007/978-1-4842-6183-5_7
7. Flowcharting
Doug Winnie1
(1) Mission Hills, KS, USA
Programming and coding are just as much about thinking and planning
as it is about sitting in front of a keyboard. Often, a developer needs to
plot out in their mind or on paper how a program is going to work. This
can make the coding process much easier, especially if you are working
together with others on a project.
A flowchart is a common way to sketch out your program. It is
exactly as it sounds: a chart that visually shows the flow of a program.
In a flowchart, you connect various steps, decisions, and actions
together into a string that follows the flow of how the program will
operate.
Because the computer is so literal with how it processes your
actions and code, a flowchart makes it easier to code more accurately
the first time vs. having to debug and thrash your way through code.
Trust me, it is tempting to ditch the flowchart and go straight to the
code, but if you are new, or relatively new to coding, it will save you a
ton of time and force you to stop, pause, and sketch things out before
you go to the keyboard.
Flowcharting Tools
There are a bunch of flowcharting tools you can use; some are pen and
paper, and some are online.
Paper
Another Random Document on
Scribd Without Any Related Topics
THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.