Ch 2: Variables & Operators in Java

About This Chapter

This Java tutorial chapter covers variables and operators in the Java programming language. You'll learn about about the purposes and functions of these variable and operator types, including static variables and bitwise operators.

Variables & Operators in Java: Chapter Summary

This comprehensive Java tutorial chapter helps you learn about the basic variables and operators used in Java. You'll identify several types of variables, such as local and static variables, as well as how assignment, arithmetic and logical operators work. The instructors in this chapter break down the purpose and functions of these variables and operators into simple definitions and examples.

These lessons are taught by expert Java instructors who present the material in an engaging and straightforward style. You'll be able to make sure you retain and internalize these Java variable and operator concepts by taking the interactive self-assessment quiz following each lesson.

The topics covered in this chapter include:

  • Static, instance and local variables
  • Final keyword in Java
  • Transient and declaring variables
  • Assignment, arithmetic, bitwise, relational and logical operators in Java

Java is a trademark of the Oracle Corporation, which is not affiliated with Study.com.

14 Lessons in Chapter 2: Variables & Operators in Java
Test your knowledge with a 30-question chapter practice test
Java Variable Types: Static, Instance & Local

1. Java Variable Types: Static, Instance & Local

Broadly speaking, there are three types of variables in Java. Learn about scope and how to use these different types of variables by looking at a simple example with a bit of code.

Java Naming Conventions: Variables & Constants

2. Java Naming Conventions: Variables & Constants

Sue has friends named Jane and Jayne. Are they the same friends? Probably not. Why? Because their names are spelt differently! Similarly the Java programming language has naming conventions for variables and constants. In this lesson we will learn about these conventions.

Java Keywords: Protected, Public & Private

3. Java Keywords: Protected, Public & Private

Java is great at protecting objects. What does it mean to protect an object? Protected, public and private are keywords used to control access. This lesson will define the concepts and provide real-world examples.

Java: Final Keyword

4. Java: Final Keyword

...And that's final! The final keyword in Java is a simple tool, but it is the programming equivalent of these words. This lesson will cover the concept of Final and provide some real-world examples how how to use the final keyword to protect and clean Java code.

Java: Transient Variables

5. Java: Transient Variables

Transient variables in Java have a special power: their values aren't stored permanently. We'll be looking at these variables and serialization in this lesson, the latter being where transient variables are most used.

Declaring Variables in Java

6. Declaring Variables in Java

You'll learn how to declare variables of various types in Java, naming conventions for variables and how declarations can be used to initialize the variable's value.

Atomic Variables in Java: Definition & Example

7. Atomic Variables in Java: Definition & Example

What if you could have a runway that allows simultaneous take-offs and landings? Although it might sound like we should be doing physics, Java has atomic variables that allow for multi-use runways. This lesson will define the concept and provide an example of an atomic variable in action.

Atomic Variables in Java: Performance & Tutorial

8. Atomic Variables in Java: Performance & Tutorial

In Java, atomic variables let us update variables quickly and simultaneously, at the atomic level. This lesson covers the performance benefits of atomic variables, and provides code examples of implementation.

Java Variable Scope: Definition & Best Practices

9. Java Variable Scope: Definition & Best Practices

Object-oriented programing lets us keep variables close to the vest, or share them with the world. In this lesson, we'll cover variable scope and provide code examples.

Java: Assignment Operators

10. Java: Assignment Operators

You'll find yourself assigning data to variables in Java often. How do you do that? This lesson will define the Java assignment operators and provide code examples of the operators in action.

Java: Arithmetic Operators

11. Java: Arithmetic Operators

A large chunk of programming involves math, from addition to multiplication to modulo operations. These math operations need not be confusing or overly complex. This lesson will cover the arithmetic operators in Java and provide working code examples.

Java: Bitwise Operators

12. Java: Bitwise Operators

Contrary to popular belief, bitwise operators are not bits that are wise. Instead, they allow programmers to work with data at the bit-level, the most granular level in computing. We will explain the concept and provide working code examples.

Java: Relational Operators

13. Java: Relational Operators

Programming is all about testing and comparing values. Are they equal, or less than, or more than? The Java relational operators help us in these operations. This lesson will explain the operators and provide syntax examples.

Java: Logical Operators

14. Java: Logical Operators

Logical statements are as integral to programming as there are in everyday life. They give us an enormous amount of power in our programs. This lesson will cover these statements in the context of Java and provide working code examples.

Chapter Practice Exam
Test your knowledge of this chapter with a 30 question practice chapter exam.
Not Taken
Practice Final Exam
Test your knowledge of the entire course with a 50 question practice final exam.
Not Taken

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Support