Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
6 views
Java Cheatsheet
Java cheatsheet
Uploaded by
jeff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Java Cheatsheet For Later
Download
Save
Save Java Cheatsheet For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
6 views
Java Cheatsheet
Java cheatsheet
Uploaded by
jeff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Java Cheatsheet For Later
Carousel Previous
Carousel Next
Save
Save Java Cheatsheet For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 2
Search
Fullscreen
THE JAVA LANGUAGE CHEAT SHEET Primitive Type: '¥ O@atukkumare INTEGER: byte (bit), short (16bit), int (32bit), Long (64bit) , DECIM: float (32bit) , double (64bit) sOTHER: boolean (bit), char (Unicode) yb00101, LONG: seseeeeeesaseL ta AM ARES INTE INE VT Primi Operators Assignment Operator: = (ex: int a=5,b=3; ) Binary Operators (two arguments): + - ° / & Unary Operators: + - ++ -- Boolean Not Operator (Unary): ! Boolean Binary: Is >see Boolean Binary Only: 45 || Bitwise Operators: ~ 6 * | << >> >>> Ternary Operator: bool?valtrue:valfalse; (int)5.57 //works for numeric types Integer.parsernt ("123"); arseFloat ("1.5"); Integer.parsernt ("7A",16); //fromHex String hex = Integer. toString (99,16) ;//toHex //erevious lines work w/ binary, other bases java.util.scanner, input, output Scanner sc = new Scanner (System.in); int i= sc.nextint(); //stops at whitespace String Line = sc.nextLine(); //whole Line System.out.printin("bla"); //stdout System.err.print ("bla"); //stderr,no newline java.lang.Number types Integer x = 5; double y = x.doubleValue(): double y = (double) x. intValue (); //Many other methods for Long, Double, etc java.lang.String Methods 7/operator +, e.g. “fat"s"cat” -> “fatcat” boolean equais (String other); int length( char charat(int i); String substring(int i, int 3)7 //j not incl boolean contains (String sub) boolean startsifith (String pre); boolean endsWith(String post) int indexof(Sering p): //-1 if not found int indexof(String p, int is //start at i int compareTo (String t); 1/*a" .compareTo ("bh") => -1 String replaceall (String str, String find); Steingl] split (String delim; StringBuffer, StringBuilder SeringSuffer is synchronized StringBuilder (Use StringBuilder unless multithreaded) Use the .apend( xyz ) methods to concat toString() converts back to String java.lang.Math Math. abs (NUM) ,Math.ceil (NUM) , Math. floor (tum) sMath. log (NUM) ,Math.max (A,B), Nath.min (C, D) Math. pow (A,B) ,Math.cound{A) ,Math.zcandom() IF_STATEMENTS : “CODING BUGS ENOTES GALLERY Tf boolean value ) ( STATEMENTS } else if( bool } ( STATEMENTS } else if( ..etc ) | STATEMENTS | else ( STATEMENTS | ‘/eurly brackets optional if one line LOOPS: while( bool ) ( STATEMENTS } for(INIT;BOOL;UPDATE) ( STATEMENTS } //AINIT 2OOL 3STATEMENTS 4UPDATE 5->step2 do( STATEMENTS Jwhile( bool ); //do loops run at least once before checking break: — //ends enclosing loop (exit loop) continue; //jumps to bottom of loop ARRAYS int{] x = new int{10]z //ten zeros int(][] * = new int(51(5]; //5 by 5 matcix int[] x = (1,2,3,4)7 x.length; //int expression length of array ant) * = (11/21, (3,4,5)}7 //ragged array String{] y = new String[10]; //10 nulls J/wove that object types are null by default / Poop through array for(int i=0;icarrayname.lengthrit+) { Jase arrayname(i]i ) //f0r-each loop through array int ({] x = (10,20, 30,4017 for(int vz x) { //¥ cycles between 10,20, 30, 40 ' //toop through ragged array for(int i=0;icx.length;i++) for(int j=07}
( T value T getValue() { return value: | 1 class ExampleTwo
{ Ax By: ’ class ExampleThree
,B> | aA lists B head; , (Note the extends keyword here applies as well to interfaces, so A can be an int that extends List
JAVA COLLECTIONS Lister: Similar to arrays ArrayListcT>: Slow insert into middl //azrayList has fast random access LinkedList
: slow random access //isnkedList fast as queue/stack Stack: Removes and adds from end List Usage: boolean add(T e); void clear(); //empties boolean contains (Object 0}; T get (int index); T remove(int index); boolean remove (Object 0): //remove uses comparator T set (int index, E val); Int size(); List Traversal: for(int isGicx.size()sit+) ( Jyase x.get (i)? ) //assuming List
: for(Te: x) { hase e 1 QueuecT>: Remove end, Insert beginning LinkedList implements Queue ‘Queue Usage: T elenent(); // does not renove boolean offer(T 0); //adds T peek(); //pike element 1 poll(): //removes T remove(); //like poll Traversal: for(T e : x) () jat<™>: uses Comparable<7> for uniqueness TreeSet
, items are sorted HashSet
, not sorted, no order LinkedHashSet
, ordered by insert Usage like list: add, remove, size Traversal: for(T e : x) () Map
: Pairs where keys are unique HashMap
, no order LinkedHashMap
ordered by insert TreeMap
sorted by keys V get(K key); Set
keySet(); //set of keys V put(K key, V value: Vv remove (K key); Int size(); Collection
values(); //all values Travercs for-each w/ kevyset/values
You might also like
JAVA Cheat Sheet
PDF
100% (1)
JAVA Cheat Sheet
12 pages
Core Java Cheatsheet
PDF
No ratings yet
Core Java Cheatsheet
17 pages
Java Cheatsheet
PDF
No ratings yet
Java Cheatsheet
2 pages
Java Cheat Sheet
PDF
No ratings yet
Java Cheat Sheet
2 pages
KT Byte Java Cheat Sheet
PDF
No ratings yet
KT Byte Java Cheat Sheet
2 pages
Lecture1 Intro Java Part1
PDF
No ratings yet
Lecture1 Intro Java Part1
51 pages
The Essential Java Cheat Sheet
PDF
No ratings yet
The Essential Java Cheat Sheet
16 pages
Java Ref Card
PDF
No ratings yet
Java Ref Card
2 pages
Oracle
PDF
No ratings yet
Oracle
70 pages
Tutorial 2 - Syntax & Grammar: Lexical Structure
PDF
No ratings yet
Tutorial 2 - Syntax & Grammar: Lexical Structure
8 pages
JAVA
PDF
No ratings yet
JAVA
15 pages
Question Paper 1 Java
PDF
No ratings yet
Question Paper 1 Java
22 pages
Session02-Learning The Java Language
PDF
No ratings yet
Session02-Learning The Java Language
34 pages
Unit_1_^0_@_Summary[1]
PDF
No ratings yet
Unit_1_^0_@_Summary[1]
44 pages
Basics of Java Presentation
PDF
No ratings yet
Basics of Java Presentation
165 pages
JSUG-Slides EffectiveJavaPuzzlers Christoph Pickl
PDF
No ratings yet
JSUG-Slides EffectiveJavaPuzzlers Christoph Pickl
36 pages
Notes - Introduction To Java
PDF
No ratings yet
Notes - Introduction To Java
16 pages
Institute: Uie Department: Cse: Java Programing (CST-205)
PDF
No ratings yet
Institute: Uie Department: Cse: Java Programing (CST-205)
33 pages
Data Structures Using Java
PDF
No ratings yet
Data Structures Using Java
16 pages
# - The Ultimate Cheatsheet: 1. Basic Syntax and Types
PDF
No ratings yet
# - The Ultimate Cheatsheet: 1. Basic Syntax and Types
14 pages
AP Computer Science A Cram Chart 2021
PDF
No ratings yet
AP Computer Science A Cram Chart 2021
1 page
Java
PDF
No ratings yet
Java
18 pages
On Java
PDF
No ratings yet
On Java
39 pages
Java Report
PDF
No ratings yet
Java Report
110 pages
Lecture1 Dsa
PDF
No ratings yet
Lecture1 Dsa
31 pages
Java Extra Notes
PDF
No ratings yet
Java Extra Notes
13 pages
Lesson 02 - Built-In Classes
PDF
No ratings yet
Lesson 02 - Built-In Classes
34 pages
Data Structures and Algorithms
PDF
No ratings yet
Data Structures and Algorithms
29 pages
Object Oriented Design and Patterns
PDF
No ratings yet
Object Oriented Design and Patterns
204 pages
Presentacion
PDF
No ratings yet
Presentacion
36 pages
_java-the-complete-reference-eleventh-edition-1-1882-pages-2-pages-2
PDF
No ratings yet
_java-the-complete-reference-eleventh-edition-1-1882-pages-2-pages-2
7 pages
3 Analysis-Streams
PDF
No ratings yet
3 Analysis-Streams
67 pages
OOPS RECORD
PDF
No ratings yet
OOPS RECORD
52 pages
Java More Details
PDF
No ratings yet
Java More Details
39 pages
SEASON-2
PDF
No ratings yet
SEASON-2
298 pages
ST 3 Practice Questions
PDF
No ratings yet
ST 3 Practice Questions
30 pages
02.1 - Learning The Java Language
PDF
No ratings yet
02.1 - Learning The Java Language
36 pages
On Java
PDF
No ratings yet
On Java
39 pages
Lecture 8 Wrapper Classes, Arrays
PDF
No ratings yet
Lecture 8 Wrapper Classes, Arrays
36 pages
ET MCQ Practice Questions
PDF
No ratings yet
ET MCQ Practice Questions
53 pages
Java Core
PDF
100% (2)
Java Core
6 pages
Java Basics Java Basics: For More Tutorials Visit For More Tutorials Visit
PDF
No ratings yet
Java Basics Java Basics: For More Tutorials Visit For More Tutorials Visit
166 pages
Java Experiment 6-15
PDF
No ratings yet
Java Experiment 6-15
41 pages
Package and Some Classes: Declaration of Package Usage of Package Package of Java Language
PDF
No ratings yet
Package and Some Classes: Declaration of Package Usage of Package Package of Java Language
34 pages
224 Questions
PDF
No ratings yet
224 Questions
36 pages
Computer Application Keynotes
PDF
No ratings yet
Computer Application Keynotes
11 pages
Introduction To Core Java (At A Glance)
PDF
No ratings yet
Introduction To Core Java (At A Glance)
72 pages
allNotes-v2-3-26-2025
PDF
No ratings yet
allNotes-v2-3-26-2025
75 pages
Refcardz Core Java PDF
PDF
100% (1)
Refcardz Core Java PDF
6 pages
Core Java
PDF
No ratings yet
Core Java
6 pages
(Always Learning) Pandey, Hari Mohan - Java Programming-Dorling Kindersley (India) - Pearson (2012)
PDF
100% (1)
(Always Learning) Pandey, Hari Mohan - Java Programming-Dorling Kindersley (India) - Pearson (2012)
889 pages
Java Tutorial: Write Once, Run Anywhere
PDF
No ratings yet
Java Tutorial: Write Once, Run Anywhere
50 pages
Lecture 8 Wrapper Classes, Arrays
PDF
No ratings yet
Lecture 8 Wrapper Classes, Arrays
36 pages
Core Java Cheat Sheet
PDF
No ratings yet
Core Java Cheat Sheet
10 pages