Aug 22, 2024
int myInt = 7;
int
is the type (integer), myInt
is the name, 7
is the value.;
).System.out.println(myInt);
to output values.int
(integer)double
(decimal)char
(character)double shoeSize = 9.5;
char myInitial = 'J';
double result = myInt * shoeSize;
String myName = "John";
myName.length()
returns the length of the string.private static void burp() { System.out.println("burp"); }
public void printName(String name) { System.out.println("My name is " + name); }
void
to String
in declaration, and use return
keyword.if
, else if
, else
statements for conditions.
if (name.equals("John")) { ... }
.==
for numeric comparisons and .equals()
for strings.for (int i = 0; i < 10; i++) { ... }
Cat
with attributes like name
and age
.new
keyword to create instances of a class.
Cat myCat = new Cat();