Show Menu
Cheatography

Java Fundamental Cheat Sheet Cheat Sheet (DRAFT) by

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 Declar­ation and Initia­liz­ation

float f = 1.2f;
Float declar­ation and initia­liz­ation
long l = 8_000_­000­_000L;
Long declar­ation and initia­liz­ation
var v = 1;
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 declar­ation and initia­liz­ation
datatype[] variable = new dataty­pe[20];
//Length of the array
variab­le.l­ength;
//Sort the array
Arrays.so­rt(­var­iable);
//Sort from one index to another index
Arrays.so­rt(­var­iable, fromIndex, endIndex);
//Binary search in-built
Arrays.bi­nar­ySe­arc­h(v­ari­able, intKey);
//Binary search in a specific range
Arrays.bi­nar­ySe­arc­h(v­ari­able, fromIndex, toIndex, intKey);
//Convert and return the array as a string
Arrays.to­Str­ing­(va­ria­ble);
//Compare two arrays if they are the same
Arrays.eq­ual­s(v­ari­able1, variab­le2);

Big Decimal

//Big Integer declar­ation
BigDecimal variable = new BigDec­ima­l("V­alu­e");
//Adding two Big Integers and returning the value.
variable3 = variab­le1.ad­d(v­ari­able2);
//Multip­lying two Big Integers and returning the value.
variable3 = variab­le1.mu­lti­ply­(va­ria­ble2);
//Subtra­cting two Big Integers and returning the value.
variable3 = variab­le1.su­btr­act­(va­ria­ble2);
//Dividing two Big Integers and returning the value.
variable3 = variab­le1.di­vid­e(v­ari­able2);
//Finds if Variable1 is Max or Variable2 is.
variable3 = variab­le1.ma­x(v­ari­able2);
//Finds if Variable1 is Min or Variable2 is.
variable3 = variab­le1.mi­n(v­ari­able2);