One Pager Cheat Sheet
- Java is a highly efficient,
object-oriented
programming language developed by James Gosling at Sun Microsystems that is designed for reliability, reusability, and security. - Java offers 8 primitive data types:
byte
,short
,int
,long
,float
,double
,boolean
, andchar
that are used to store values of various sizes and types. - Referential types like
Strings
,Classes
, andObjects
, which are created by the programmer, have a default value ofnull
and refer to objects. - Variables in Java are
references
to memory which are declared in different scopes (Local
,Instance
,Static
) and cannot be accessed beyond their scope. - Instance variables are declared inside classes and have different values for each instantiated object, while static variables are
shared
among all instances of a class. - In Java, user input can be taken in three ways:
Using Scanner
,Console
class, andBufferedReader
class. - A
Java
program consists of Classes, Objects, Variables and Methods. - In order to compile a Java program, you must save it as a
.java
file and then call the compiler with thejavac
command before running it with thejava
command. - Iterative statements, such as
for
andwhile
loops, allow us to repeat statements until a certain condition is met, such as in the classic Fizz Buzz problem. Decisive Statements
in Java, such asif
andelse if
statements, allow you to control the flow of execution depending on conditions known only during runtime.- Arrays in Java are the most primitive way of aggregating
elements of the same datatypes
and can be declared and initialized either withcurly braces
or thenew keyword
. Strings in Java
are immutable objects represented by thejava.lang.String
class, which implements theSerializable
,Comparable
, andCharSequence
interfaces, and Java offers two mutable utility classes:StringBuilder
andStringBuffer
, with the latter being thread-safe.- Java is an Object-Oriented programming (OOP) language with
classes
,objects
,constructors
, and methods used toimplement
the four basic principles of OOP, namelypolymorphism
,abstraction
,inheritance
, andencapsulation
.