Cheatography
https://cheatography.com
Java Fundamental Cheat Sheet: A concise reference guide outlining key concepts, syntax, and best practices for Java programming beginners and enthusiasts.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
To run Java Program using Bat Script
@echo off
javac *.java
java filename
del *.class
|
Datatype Declaration and Initialization
|
Float declaration and initialization |
long l = 8_000_000_000L;
|
Long declaration and initialization |
|
Variable type inference |
Arrays
//Declaration of Array Datatype.
datatype[] variable = new datatype[20];
//Returns Length of the array.
variable.length;
//Sort the array.
Arrays.sort(variable);
//sort from one index to another index.
Arrays.sort(variable,fromIndex,endIndex);
//Binary Search in-built.
Arrays.binarySearch(variable,intKey);
//Binary Search in a Specific Range.
Arrays.binarySearch(variable,fromIndex,toIndex,intKey);
//Converts and returns the array as String.
Arrays.toString(variable)
//Compare two arrays if they are same.
Arrays.equals(variable1,variable2);
|
|
|
Arrays
//Array declaration and initialization
datatype[] variable = new datatype[20];
//Length of the array
variable.length;
//Sort the array
Arrays.sort(variable);
//Sort from one index to another index
Arrays.sort(variable, fromIndex, endIndex);
//Binary search in-built
Arrays.binarySearch(variable, intKey);
//Binary search in a specific range
Arrays.binarySearch(variable, fromIndex, toIndex, intKey);
//Convert and return the array as a string
Arrays.toString(variable);
//Compare two arrays if they are the same
Arrays.equals(variable1, variable2);
|
Big Decimal
//Big Integer declaration
BigDecimal variable = new BigDecimal("Value");
//Adding two Big Integers and returning the value.
variable3 = variable1.add(variable2);
//Multiplying two Big Integers and returning the value.
variable3 = variable1.multiply(variable2);
//Subtracting two Big Integers and returning the value.
variable3 = variable1.subtract(variable2);
//Dividing two Big Integers and returning the value.
variable3 = variable1.divide(variable2);
//Finds if Variable1 is Max or Variable2 is.
variable3 = variable1.max(variable2);
//Finds if Variable1 is Min or Variable2 is.
variable3 = variable1.min(variable2);
|
|