Advanced Placement Computer Science A focusing on Java programming and object-oriented design.
Computers need to store information and perform calculations. In Java, we use variables to store data, data types to define the kind of data, and operators to manipulate it.
int
: Whole numbers (e.g., 10, -3)double
: Decimal numbers (e.g., 3.14, -0.001)boolean
: True or falsechar
: Single characters, like 'A' or 'z'String
: Text, like "Hello!"+
, -
, *
, /
, %
=
, +=
, -=
==
, !=
, <
, >
, <=
, >=
&&
, ||
, !
int age = 16;
double price = 4.99;
boolean isStudent = true;
String name = "Taylor";
if (isStudent && age < 18) {
System.out.println(name + " gets a discount!");
}
Variables and operators are everywhere: from banking systems tracking balances to video games calculating health points.
Using int
to count the number of books in a library.
Checking if a user is old enough to drive using comparison operators.
Variables hold data, data types define the kind of data, and operators let you perform calculations and checks.