Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

Well - and - Good - Java Cheat Sheet

Uploaded by

Ashutosh Panda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Well - and - Good - Java Cheat Sheet

Uploaded by

Ashutosh Panda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Cheat Sheet

Core Concepts
Data Types:
● Primitive: byte, short, int, long, float, double, boolean, char
● Reference: String, Array, Class, Interface
Variables and Operators:
● Declaration: datatype variableName;
● Assignment: variableName = value;
● Operators: Arithmetic (+, -, *, /, %), Comparison (==, !=, >, <, >=, <=), Logical (&&, ||, !),
Bitwise (&, |, ^, ~, <<, >>, >>>)
Control Flow:
● if/else: Conditional execution.
● switch: Multiple-choice execution.
● for: Looping a specific number of times.
● while: Looping while a condition is true.
● do-while: Looping at least once, then while a condition is true.
Arrays:
● Declaration: datatype[] arrayName = new datatype[size];
● Access: arrayName[index]
Strings:
● Concatenation: + operator
● Methods: length(), charAt(), indexOf(), substring(), toLowerCase(), toUpperCase(), trim()
Object-Oriented Programming (OOP)
Classes and Objects:
● Class: A blueprint for creating objects.
● Object: An instance of a class.
Inheritance:
● Single Inheritance: A class inherits from one parent class.
● Multiple Inheritance: A class inherits from multiple parent classes (not directly supported
in Java, but achieved using interfaces).
Polymorphism:
● Method Overloading: Multiple methods with the same name but different parameters.
● Method Overriding: A subclass provides a specific implementation of a method inherited
from a superclass.
Encapsulation:
● Hiding the implementation details of a class and exposing only the necessary interface.
Abstraction:
● Focusing on the essential features of an object and ignoring unnecessary details.
Exception Handling
● try-catch-finally: Used to handle exceptions.
● throw: Throws an exception.
Input/Output
● File I/O: FileReader, FileWriter, BufferedReader, BufferedWriter, FileInputStream,
FileOutputStream
● Console I/O: Scanner, System.out.println()
Collections Framework
● List: ArrayList, LinkedList
● Set: HashSet, TreeSet, LinkedHashSet
● Map: HashMap, TreeMap, LinkedHashMap
Generics
● Type Safety: Ensures that only objects of a specific type can be stored in a collection or
passed as a method argument.
Threads
● Creating Threads: Thread class, Runnable interface
● Thread Synchronization: synchronized keyword
Java APIs
● Java API: A vast collection of classes and interfaces for various tasks.
● Core APIs: java.lang, java.util, java.io, java.net, etc.
● Swing and AWT: For creating GUI applications.
● JavaFX: A modern UI toolkit for Java.
Remember to practice coding regularly and refer to the official Java documentation for
in-depth information.

You might also like