can be a class name, method name, variable name, or label.
making your code readable and understandable.
Rules for naming Identifiers in Java:
Must begin with a letter, underscore (_), or dollar sign ($).
Cannot start with a digit. Can contain letters (a-z, A-Z), digits (0-9), underscores (_), and dollar signs ($) after the first character.
Cannot be a reserved keyword. Case-sensitive: Distinct identifiers may vary in case (e.g., myVariable, MyVariable, and myvariable).
No length limit, but clarity is recommended.
Spaces are not allowed; underscores or camelCase are preferred for readability.
TYPE CASTING
refers to converting a value of one data type into another.
Two types of Type Casting:
Widening Conversion
Narrowing Conversion
Widening Conversion (Implicit Type Casting)
converting a smaller data type to a larger data type.
Narrowing Conversion ( Explicit Type Casting )
This type of casting occurs when you're converting a larger data type to a smaller data type. It might result in loss of data, so it requires explicit casting.
JAVA OPERATORS
symbols used to perform operations on variables and values.
Java operators can be categorized into five categories:
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Bitwise operators
ARITHMETIC OPERATORS
used to perform arithmetic operations on variables and data.
ARITHMETIC OPERATORS
addition +
subtraction -
Multiplication *
division /
Modulus %
Increment ++
Decrement –
ASSIGNMENT OPERATORS
used in Java to assign values to variables.
ASSIGNMENT OPERATORS
=
+=
-=
*=
/=
%=
COMPARISON OPERATORS
used to compare values and determine the relationship between them. (true or false)
COMPARISON OPERATORS
==
!=
>
<
>=
<=
COMPARISON OPERATORS
used to check whether an expression is true or false.
COMPARISON OPERATORS
&& (logicalAND)
|| (logicalOR)
! (logicalNOT)
JAVA STRING
a class in the Java programming language that represents a sequence of characters.
length()
Give an exact number of strings starting from 1
charAt()
Give character at a specific index (starts
substring(int beginIdx)
Give a substring from the given index
substring(int beginIdx, intlastIdx)
Give a substring starting from begin index & ending at the last index
indexOf()
Give the index of the first ask specified substring w/in a string
startsWith()
boolean vName = name.startsWith()
println(vName) // true if (“Gerry”)
Check if the string starts with the specified prefix.
endsWith()
Checks if the string ends with the specified suffix.
toUpperCase()
Converts all characters in the string to uppercase.
toLowerCase()
Converts all characters in the string to lowercase.
replace()
searches a string for a specified character, and returns a new string where the specified character(s) are replaced.