Sunday, 3 September 2017

Ultimate Java Programming Cheatsheet

Ultimate Java Programming Cheatsheet

Java Programming Cheatsheet

Java is one of the most popular, most adopted and general purpose programming language used by millions of developers and billions of devices around the world. It is a class-based, object-oriented language and designed to be portable, which means that you can find it on all platforms, operating systems, and devices. It is used to develop all kinds of Android apps, desktop apps, and video games. It is also commonly used as a server-side language for enterprise-level back end development. This programming language has long-term compatibility and developers are comfortable with Java.
Cheat-sheet for Java Programming is given below:

Java Data Types

Data type specifies the size and type of values that can be stored in an identifier. The Java language is rich in its data types. Different data types allow you to select the type appropriate to the needs of the application.

Data types in Java are classified into two types:

Primitive—which include Integer, Character, Boolean, and Floating Point.
Non-primitive—which include Classes, Interfaces, and Arrays.

byte / short / int / long
float / double
true, false
“­Keep Following Techworm”

Java Data Conver­sions

String to Number
int i = Intege­r.p­ars­eIn­t(­str);
double d =­rse­Dou­ble­(s­tr);
Any Type to String
String s =­lue­Of(­va­lue);
Numeric Conver­sions
int i = (int)

Java Arithmetic Operators

x + y
x – y
x * y
x / y
x % y
++x / x++
–x / x–

Java Comparison Operators

x < y
x <= y
Less or eq
x > y
x >= y
Greater or eq
x == y
x != y
Not equal

Java Boolean Operators

! x (not)
x && y (and)
x || y (or)

Java Text Formatting

printf style format­ting
System.ou­t.p­rin­tf(­”­Count is %d\n”, count);
s =­rma­t(“Count is %d”, count);Mess­age­Format style format­ting
s = Messag­eFo­rma­t.f­ormat(
 ­”At {1,time}, {0} Runs Scored.”,
 25, new Date());Indi­vidual Numbers and Dates
s = Number­For­­tCu­rre­ncy­()
s = new Simple­Dat­eFo­rma­t(“”yyyy/mm/dd””)
 .fo­rma­t(new Date());

Java Hello World

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello, World");


Java String Methods

length of s­arA­t(i)
extract ith character­bst­rin­g(­startend)
substring from start to end-1­Upp­erC­ase()
returns copy of s in ALL CAPS­Low­erC­ase()
returns copy of s in lowercase­dex­Of(x)
index of first occurence of x­pla­ce(­oldnew)
search and replace
splits string into tokens
trims surrou­nding whitespace
true if s equals s2­mpa­reT­o(s2)
0 if equal/+ if s > s2/- if s < s2

Java Statements

If Statem­ent
if ( expre­ssion ) {
} else if ( expre­ssion ) {
} else {
}While Loop
while ( expre­ssion ) {
}Do-While Loop
do {
} while ( expre­ssion );For Loop
for ( int i = 0; i < max; ++i) {
}For Each Loop
for ( var : colle­ction ) {
}Switch Statem­ent
switch ( expre­ssion ) {
 case value:
 ­ ­ ­st­ate­ments
 ­ ­ ­break;
 case value2:
 ­ ­ ­st­ate­ments
 ­ ­ ­break;
 ­ ­ ­st­ate­ments
}Exce­ption Handling
try {
} catch (Exce­pti­onType e1) {
} catch (Exception e2) {
 ­cat­ch-all statem­ents;
} finally {

Applications of Java

Java is being used in:

  1. Real-time Systems
  2. Simulation and Modelling
  3. object oriented Databases
  4. Artificial Intelligence and Expert Systems
  5. CIM/CAD/CAM Systems
  6. Neural Networks and Parallel Programming
  7. Decision Support Systems

Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...


:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

Posts RSSComments RSSBack to top
© 2013 ComboUpdates - Powered by Blogger
Released under Creative Commons 3.0 CC BY-NC 3.0