Cheatography
https://cheatography.com
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];
mylist2[e2] = mylist[e1];
mylist2[e2] = temp;
for (int i : mylist){
System.out.println(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 |
Previous/Next tab |
Alt-Left/Right |
Back/Forward in code |
Ctrl-Alt-Left/Right |
Last edit location |
Ctrl-Shift-Backspace |
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.out.println(x);
x++;
for loop
for (int a = 0; a < 10; a++){
System.out.println(a);
Enchanted for loop
int number[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
for (int a: number) {
System.out.println(a);
while..do loop
int x = 1;
do{
System.out.println( x );
x++;
}
while( x < 10 );
|
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets