Configuration

Night mode

Expressions

Java Basics Course

Engineers From These Top Companies and Universities Trust EXLskills

1M+ Professionals | 100+ Institutions

This is the EXLskills free and open-source Java Basics Course. It guides learners via explanation, demonstration, and thorough practice, from no more than a basic understanding of Java, to a moderate level of essential coding proficiency.

Is this course FREE?

Yes, this a 100% free course that you can contribute to on GitHub here!

Have more questions?

Operators

Expressions

An expression is a mixture of literals, operators, variable names, and parentheses used to calculate a value. Please keep in mind that in Java, the expression on the right side of the assignment statement is evaluated first. The expressions will look similar to regular mathematical expressions from math class. Please take a look at the expressions below.

Expressions can be written without using any spaces at all, but the use of one or more spaces to visually separate the parts without changing the meaning is useful for the programmer and reader.

Keep in mind the discussion we had previously on division of integers. If the operands are integers, these operators will perform integer arithmetic. If one or both operands are floating points, the operators will perform floating point arithmetic. Any number with a decimal would result in a double or float. For integers, 5/2 results in 2. For floating point, 5.0/2.0 results in 2.5 and 5/2.0 results in 2.5.