Java tutorial for beginners and professionals with examples on Basics, OOPs, Methods, Overloading, Overriding, Inheritance, Polymorphism, Interfaces, Packages, Abstract classes, String handling, Exception handling, IO, Collections, Multithreading, Serialization and more.
As we are going to start learn Java, which is a programming language. So, let us have a brief look at programming language first.
What is language?
A way of communication is known as language. e.g. Hindi, English etc.
What is a Program?
A set of instructions which is used to perform a specific task.
What is a Programming Language?
An artificial language used to write programs which can be translated into machine language and executed by computer with the help of some special software.
What is a Platform?
Dictionary meaning: A raised level surface on which things can stand.
In programming: Hardware or software on which a program can execute/run.
e.g. – c, c++, Java etc.
What is Java?
Java is a high level programming language and also known as platform because of its JRE (java runtime environment).
Brief History of Java.
Java language project initially started in June 1991 by James Gosling, Mike Sheridan, and Patrick Naughton. An oak tree stood outside Gosling’s office at that time and java named as oak initially. It later renamed as Green and was later renamed as java from java coffee.
Base concept of java language project.
Write once, run anywhere (WORA) – that means java program can run anywhere and on any platform. When java code is compiled it is converted into byte code. Now only this byte code is needed to run using JVM, no need of source code and recompilation.
Java released versions:
1. JDK Alpha and Beta (1995)
2. JDK 1.0 (23rd Jan, 1996)
3. JDK 1.1 (19th Feb, 1997)
4. J2SE 1.2 (8th Dec, 1998)
5. J2SE 1.3 (8th May, 2000)
6. J2SE 1.4 (6th Feb, 2002)
7. J2SE 5.0 (30th Sep, 2004)
8. Java SE 6 (11th Dec, 2006)
9. Java SE 7 (28th July, 2011)
10. Java SE 8 (18th March, 2014)
11. Java SE 9 (21th Sept, 2017)
12. Java SE 10 (20th March, 2018)
13. Java SE 11 (25th Nov, 2018)
14. Java SE 12 (19th March, 2019)
- JVM (java virtual machine) architecture details.
- Difference between JVM, JRE and JDK.
- Java Coding Guidelines.
- Some important definitions for java programs.
- Variable and data types.
- Hello world java program.
- Java examples programs.
- How to set permanent path?
- OOPs Basics.
- Object and Class.
- OOPs Principles/Concepts.
- Method overloading
- Method overriding
- Dynamic method dispatch or Runtime polymorphism
- Inheritance with examples
- Command line arguments
- How to execute command line argument program in eclipse.
- How to read input from command line using Scanner
- Abstract class
- Custom marker Interface
- Access modifier
- Static import
- Package class
- Instance initialize/ Anonymous block
Java string handling tutorial:
- String handling
- String Comparison
- String concatenation
- Immutable class
- toString() method
- Commonly used methods of String Class with example
- charAt(int index) String function
- startsWith(String prefix) and endsWith(String suffix) String functions
- indexOf(String str) and lastIndexOf(String str) String functions
- toLowerCase() and toUpperCase() String functions
- intern() String functions
- length() String functions
- trim() String functions
- String to int
- String to integer with leading zeros
- Int to string
- String to double
- Double to string
- String to long
- Long to string java
- String to boolean
- Boolean to string
- Char to string
- String to char
- Char array to string
- String to date
- Date to string
- Ascii to string
- Float to string
- String to arraylist
- String Performance Hints
Java StringBuffer tutorial:
- append(String str) StringBuffer method
- insert(int offset, String str) StringBuffer method
- replace(int startIndex, int endIndex, String str) StringBuffer method
- delete(int startIndex, int endIndex) StringBuffer method
- reverse() StringBuffer method
- capacity() StringBuffer method
- ensureCapacity(int minCapacity) StringBuffer method
Java StringBuilder tutorial:
- append(String str) StringBuilder method
- insert(int offset, String str) StringBuilder method
- replace(int startIndex, int endIndex, String str) StringBuilder method
- delete(int startIndex, int endIndex) StringBuilder method
- reverse() StringBuilder method
- capacity() StringBuilder method
- ensureCapacity(int minCapacity) StringBuilder method
Java StringTokenizer tutorial:
Java exception handling tutorial:
- Exception handling
- try and catch blocks
- Multiple catch blocks
- Nested try block
- Exception propagation
- Exception handling with method overriding
- Custom exception
- Throwable class
Java Multithreading tutorial:
- Thread life cycle
- Way of creating thread
- Which is a better way to create a thread?
- Methods of Thread class
- Difference between thread start and run method
- Why we call start method in thread?
- Can we override start method?
- Can we override run method?
- Is it possible to start a thread twice?
- Thread scheduling
- Thread priority
- Naming a thread
- What is join method?
- How to get current thread?
- Daemon thread
- Can we call run method directly?
- What is the difference between sleep and yield method?
- Inter-thread communication
- Synchronized method
- Static synchronization
- Synchronized block
Java concurrency tutorial
- Concurrency issues
- Concurrency solutions
- Atomic variable
- Atomic boolean
- Atomic integer
- Atomic long
- Atomic integer array
- Atomic long array
- Thread pool
- Thread group
- Shutdown hook
- Executor framework
- Fork join
- Callable and Future
- Runnable vs Callable
Java input output stream tutorial:
- FileInputStream and FileOutputStream
- Byte Streams
- DataInputStream and DataOutputStream
- BufferedInputStream and BufferedOutputStream
- FileReader and FileWriter
- How To Check If A File Exists
- List all file names from directory java
- Read all files from folder java
- Filter the files by file types java
- Read file content in byte array java
- Read file content line by line java
- Get file list from a folder filtered by extensions java
- Get file uri reference java
- Store and read objects from a file java
- Create and store property file dynamically java
- Store property file as xml file
- Get file last modified time java
- Convert byte array to inputstream java
- Convert inputstream to bufferedreader java
- Convert byte array to bufferedreader java
- Set file permissions
- Create temporary file
- Store data into temporary file
- Delete temporary file
- Write string content to file java
- Write byte content to a file java
- Delete file
- Rename file
- Make a file read only
- Check if file is writable java
- Make a read only file writable
- Check if a file is hidden
- Collection interfaces
- Set interface
- SortedSet interface
- List interface
- Map interface
- Map.Entry interface
- SortedMap interface
- Queue interface
- Deque interface
- Enumeration interface
- Collection classes
- Abstract classes in collection framework
- Comparable interface
- Comparator interface
- Properties class
- ListIterator interface
- Java Vector class
- ArrayList vs LinkedList vs Vector
- Iterator vs ListIterator vs Enumeration
- List vs Set Vs Map
- HashSet vs LinkedHashSet vs TreeSet
- HashMap vs LinkedHashMap vs TreeMap vs HashTable
- HashSet vs HashMap vs HashTable
- Collection vs collections
- Comparable vs Comparator interfaces
- Java hashcode and equals methods
- How HashMep works internally?
- How hashmap stores null key?
- How hashset works internally?
- Collection framework interview programs