0% found this document useful (0 votes)
54 views

JAVA Cheat Sheet: by Via

This document provides a cheat sheet on Java basics including data types, commands, loops, abbreviations, and classes. It lists common Java data types like byte, short, int, long, boolean, char, float, and double along with their bit sizes and value ranges. It also covers Java commands, loops like for, while, do-while and for-each, and abbreviations like JVM, JRE, JDK. The cheat sheet describes encapsulation, swapping variables, and defining a simple class with methods.

Uploaded by

tarik marrakech
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

JAVA Cheat Sheet: by Via

This document provides a cheat sheet on Java basics including data types, commands, loops, abbreviations, and classes. It lists common Java data types like byte, short, int, long, boolean, char, float, and double along with their bit sizes and value ranges. It also covers Java commands, loops like for, while, do-while and for-each, and abbreviations like JVM, JRE, JDK. The cheat sheet describes encapsulation, swapping variables, and defining a simple class with methods.

Uploaded by

tarik marrakech
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

JAVA Cheat Sheet

by pca221 via cheatography.com/25815/cs/8969/

Data Types Commands

byte 8 bits -27 to 2 7 - 1 \n new line

short 16 bits -215 to 2 15 - 1 \t tab

int 32 bits -231 to 2 31 - 1 \" "

long 64 bits -263 to 2 63 - 1 \' '

\\ \
boolean true \ false

char 16 bit unicode -215 to 2 15 - 1


Do - While loop
float 32 bit decimal -231 to 2 31 - 1
do {
double 64 bit decimal -263 to 2 63 - 1
​ ​ ​//codes
} while (condi​tion);
Encaps​ulation

public user can see For Loop List


private hide from user
int mylist = {100,200,300,400};
for(int item = 0; item< mylist.le​ngth; iterm++){
Swap
​ ​//codes
int temp = e1; }
e1 = e2; for(int item mylist) {
e2 = temp; ​ ​//codes
}
While loop

while(condition) { Abbrev​iation

//codes JVM JAVA Virtual Machine


} JRE JAVA Runtime Enviro​nment

JDK JAVA Develo​pment Kit


For Loop Array
bytecode interm​ediate level long
string word = "Hello";
compiler JAVA -> Bytecode
for (char c: word.t​oCh​arA​rra​y()){
Java Runtime bytecode -> machine
​ ​ ​ ​ ​sys​tem.ou​t.p​rin​tln()
native compiler directly to machine
​ ​ ​ ​ ...
}
Array

Class int[] mylist = new int[2]


mylist[0] = 100;
public class ABCD {
mylist[1] = 200;
​ ​ ​ ​ ​public A () {
int[] mylist = {100, 200}
​ ​ ​ ​ ​ ​ ​ ​ ​ ​//codes
​ ​ ​ ​ }
​ ​ ​ ​ ​public void B() {
​ ​ ​ ​ ​ ​ ​ ​ ​ ​//codes
​ ​ ​ ​ }
}
*public A = default, run automatic
*public void B = need call

By pca221 Published 9th September, 2016. Sponsored by Readability-Score.com


cheatography.com/pca221/ Last updated 9th September, 2016. Measure your website readability!
Page 1 of 1. https://readability-score.com

You might also like