© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
J. FriesenLearn Java Fundamentalshttps://doi.org/10.1007/979-8-8688-0351-2_3

3. Expressions

Jeff Friesen1  
(1)
Dauphin, MB, Canada
 

Computer programs manipulate data via expressions. This chapter introduces you to expressions in terms of simple and compound expressions.

Introducing Expressions

An expression is a combination of literals, variable names, method calls (discussed in Chapter 6), and operators. At runtime, the expression evaluates to a type referred to as the expression’s type.

If an expression is being assigned to a variable, their types must agree (it must be possible to convert from one type to the other without losing information) or else the compiler ...

Get Learn Java Fundamentals: A Primer for Java Development and Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.