Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let application developers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile.
Java has various data types to store different types of values. Here are some basic ones:
int
: Stores integer values (whole numbers).double
: Stores floating-point numbers (numbers with decimals).boolean
: Stores true or false values.char
: Stores a single character.String
: Stores a sequence of characters (text).
int age = 30;
double price = 19.99;
boolean isJavaFun = true;
char initial = 'J';
String greeting = "Hello, Java!";
Java supports various operators for performing operations on variables and values.
+
, -
, *
, /
, %
==
, !=
, >
, <
, >=
, <=
&&
(AND), ||
(OR), !
(NOT)
int a = 10;
int b = 5;
int sum = a + b; // sum is 15
boolean isEqual = (a == b); // isEqual is false
boolean isTrue = a > 0 && b >