Chapter 2. Java Syntax from the Ground Up
This chapter is fairly dense but should provide a comprehensive introduction to Java syntax. It is written primarily for readers who are new to the language but have some previous programming experience. Determined novices with no prior programming experience may also find it useful. If you already know Java, you should find it a useful language reference. The chapter includes some comparisons of Java to JavaScript, Python, C, and C++ for the benefit of programmers coming from those languages.
Tip
If you want to skip ahead and start writing simple Java programs straightaway, you can always jump ahead to Chapter 3 and then use this chapter as a reference that you can look back at as you work your way through that material.
In this chapter, we’ll document the syntax of Java programs by starting at the very lowest level of Java syntax and building from there, moving on to increasingly higher orders of structure. We’ll cover:
-
The characters used to write Java programs and the encoding of those characters.
-
Literal values, identifiers, and other tokens that constitute a Java program.
-
The data types that Java can manipulate.
-
The operators used in Java to group individual tokens into larger expressions.
-
Statements, which group expressions and other statements to form logical chunks of Java code.
-
Methods, which are named collections of Java statements that can be invoked by other Java code.
-
Classes, which are collections of methods ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access