Show Menu
Cheatography

Basic Java data Cheat Sheet by

Java Data

byte
8 bits
short
16 bits
int
32 bits
long
64 bits
boolean
bit
char
16 bit unicode
float
32 bit unicode
double
64 bit unicode

Swapping

public static void swap(int[] list, int e1, int e2) {
int[] mylist = {1, 2, 3, 4, 5};
int[] mylist2 = new int[9];
int temp;
temp = mylist­[e1];
mylist­2[e2] = mylist­[e1];
mylist­2[e2] = temp;
for (int i : mylist){
System.ou­t.p­rin­tln(i);
}

Char

Char is same with string but char for only letter!!

String letter = "­­A";
 

String and Arrays

String
String name = "­Whatever you want"

Array
Array[0] = 1
Array[1] = 2
Array[2] = 3

Make the class

1.Click Src
2.Click New
3.Java Class
4. Insert name
5. Type the code down

Some trick

Switch tabs
Ctrl-Tab
Prev­i­ou­­s/N­ext tab
Alt-Le­­ft­/­Right
Back­/­Fo­­rward in code
Ctrl-A­­lt­-­L­ef­­t/Right
Last edit location
Ctrl-S­­hi­f­t­-B­­ack­­space

While loop

While loops

        int count = 0;
        while (count < mylist.lenght) {
            System.out.print( mylist[count] + "");
            
            count ++;
 

Some code

/n = new line
/t = tap
/" = "
/* = multiple
// = /

For Loop

while loop
int x = 1;

while (x < 10) {
System.ou­t.p­rin­tln(x);
x++;

for loop
for (int a = 0; a < 10; a++){
System.ou­t.p­rin­tln(a);
Ench­anted for loop
int number[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

for (int a: number) {
System.ou­t.p­rin­tln(a);
whil­e..do loop
int x = 1;

do{
System.ou­t.p­rintln( x );
x++;
}
while( x < 10 );
   

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Cypressio Cheat Sheet
          Selenium WebDriver Cheat Sheet Cheat Sheet
          ISTQB Test Automation Engineering Cheat Sheet