JAVA Cheat Sheet

A Programming › Java cheat sheet in English by pca221
17,777 views 3,604 downloads 9 Sep 2016 History
3.7 avg · 0 ratings

Data Types

byte
8 bits
-27 to 27 - 1
short
16 bits
-215 to 215 - 1
int
32 bits
-231 to 231 - 1
long
64 bits
-263 to 263 - 1
boolean
true \ false
char
16 bit unicode
-215 to 215 - 1
float
32 bit decimal
-231 to 231 - 1
double
64 bit decimal
-263 to 263 - 1

Encaps­ulation

public
user can see
private
hide from user

Swap

int temp = e1;
e1 = e2;
e2 = temp;

While loop

while(condition) {
//codes
}

For Loop Array

string word = "Hello";
for (char c: word.toCharArray()){
     system.out.println()
     ...
}

Class

public class ABCD {
     public A () {
          //codes
     }
     public void B() {
          //codes
     }
}




*public A = default, run automatic
*public void B = need call

Commands

\n
new line
\t
tab
\"
"
\'
'
\\
\

Do - While loop

do {
   //codes
} while (condition);

For Loop List

int mylist = {100,200,300,400};
for(int item = 0; item< mylist.length; iterm++){
  //codes
}

for(int item mylist) {
  //codes
}

Abbrev­iation

JVM
JAVA Virtual Machine
JRE
JAVA Runtime Enviro­nment
JDK
JAVA Develo­pment Kit
bytecode
interm­ediate level long
compiler
JAVA -> Bytecode
Java Runtime
bytecode -> machine
native compiler
directly to machine

Array

int[] mylist = new int[2]
mylist[0] = 100;
mylist[1] = 200;

int[] mylist = {100, 200} 

Badges

Nice Cheat Sheet Good Cheat Sheet Downloaded from Unusual Locations × 1

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.