Introduction To
JAVA
Java is a general-purpose programming language that is class-based, object-oriented and designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA) meaning that compiled Java code can run on all platforms that support Java without the need for recompilation Java applications are typically compiled to "bytecode" that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but it has fewer low-level facilities than either of them. As of 2018, Java was one of the most popular programming languages in use according to GitHub particularly for client-server web applications, with a reported 9 million developers.
History
James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time. The language was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee. Gosling designed Java with a C/C++-style syntax that system and application programmers would find familia
This course will guide you through the basics to advanced level of Java programming with subsequent examples and programs to make your learning much faster
Course Structure
Overview
- Java How to start learning Java
- Setting up the environment in Java
- Beginning Java programming with Hello World Example
- Java Naming Conventions
- How JVM Works – JVM Architecture?
- Java Virtual Machine (JVM) Stack Area
- JVM Shutdown Hook in Java
- Java Class File
- Differences between JDK, JRE and JVM
- Does JVM create object of Main class (the class with main())?
- How is Java platform independent?
- JDBC Drivers
- Is main method compulsory in Java?
- Myth about the file name and class name in Java
- How to run java class file which is in different directory?
- Microservices Introduction
- Using predefined class name as Class or Variable name in Java
- How do I become a good Java programmer?
Basics
- Java Identifiers
- Data types in Java
- enum in Java
- Enum with Customized Value in Java
- StringBuffer appendCodePoint() Method in Java with Examples
- Variables in Java
- Scope of Variables In Java
- Blank Final in Java
- Bounded types with generics in Java
- Loops in Java
- For-each loop in Java
- For Loop in Java Important points
- Decision Making in Java (if, if-else, switch, break, continue, jump)
- Switch Statement in Java
- String in Switch Case in Java
- Do we need forward declarations in Java?
- Widening Primitive Conversion in Java
- Type conversion in Java with Examples
- Comments in Java
- Does Java support goto?
- Interesting facts about null in Java
- Using _ (underscore) as variable name in Java
- Currying Functions in Java with Examples
- Using underscore in Numeric Literals in Java
- Binary Search in Java
- Sorting in Java
OOP concepts
- Classes and Objects in Java
- How are Java objects stored in memory?
- Different ways to create objects in Java
- How to swap or exchange objects in Java?
- Encapsulation in Java
- Abstraction in Java
- Dynamic Method Dispatch or Runtime Polymorphism in Java
- Association, Composition and Aggregation in Java
- Access and Non Access Modifiers in Java
- Access Modifiers in Java
- Output of Java program Set 22 (Overloading)
- Overriding in Java
- Output of Java program Set 18 (Overriding)
- Understanding “static” in “public static void main” in Java
- Can we Overload or Override static methods in java ?
- Shadowing of static functions in Java
- Static methods vs Instance methods in Java
- Covariant return types in Java
- Static class in Java
- Flexible nature of java.lang.Object
- Instance Variable Hiding in Java
- Static blocks in Java
- The Initializer Block in Java
- Instance Initialization Block (IIB) in Java
- Static vs Dynamic Binding in Java
- Why Java is not a purely Object-Oriented Language?
- Understanding Classes and Objects in Java
Inheritance
- Inheritance in Java
- Java and Multiple Inheritance
- Java Object Creation of Inherited Class
- Inheritance and constructors in Java
- Interfaces and Inheritance in Java
- Using final with Inheritance in Java
- Accessing Grandparent’s member in Java using super
- Can we override private methods in Java?
- More restrictive access to a derived class method in Java
- Parent and Child classes having same data member in Java
- Object Serialization with Inheritance in Java
- Referencing Subclass objects with Subclass vs Superclass reference
- Does overloading work with Inheritance?
- Output of Java Program Set 20 (Inheritance)
Operators
Input and Output
- Character Stream Vs Byte Stream in Java
- DoubleStream mapToObj() in Java
- Command Line arguments in Java
- Scanner Class in Java
- Scanner and nextChar() in Java
- Difference between Scanner and BufferReader Class in Java
- Formatted output in Java
- Fast I/O in Java in Competitive Programming
- Ways to read input from console in Java
Strings in Java
- StringTokenizer class in Java with example Set 1 ( Constructors)
- StringTokenizer methods in Java with Examples Set 2
- Java.util.StringJoiner in Java8
- How to Initialize and Compare Strings in Java?
- String vs StringBuilder vs StringBuffer in Java
- When to use StringJoiner over StringBuilder?
- Different ways for Integer to String Conversions In Java
- String to Integer in Java – parseInt()
- Swap two Strings without using third user defined variable in Java
- Searching characters and substring in a String in Java
- Compare two Strings in Java
- Reverse a string in Java
- Remove Leading Zeros From String in Java
- Trim (Remove leading and trailing spaces) a string in Java
- Counting number of lines, words, characters and paragraphs in a text file using Java
- Check if a string contains only alphabets in Java using Lambda expression
- Remove elements from a List that satisfy given predicate in Java
- Check if a string contains only alphabets in Java using ASCII values
- Check if a string contains only alphabets in Java using Regex
- Check if two strings are same ignoring their cases Convert Java Object to Json String using GSON Move all Uppercase char to the end of string Convert Java Object to Json String using Jackson API Insert a String into an
Arrays in Java
- Arrays in Java
- Default array values in Java
- Arrays class in Java
- Final arrays in Java
- Interesting facts about Array assignment in Java
- Jagged Array in Java
- Understanding Array IndexOutofbounds Exception in Java
- Array vs ArrayList in Java
- How to compare two arrays in Java?
- ArrayList to Array Conversion in Java : toArray() Methods
- Merge arrays into a new object array in Java
- Check if a value is present in an Array in Java util.Arrays vs reflect.Array in Java with Examples Remove all occurrences of an element from Array in Java How do Dynamic arrays work? Maximum number of Unique integers i
Stream in Java
- Stream ofNullable(T) method in Java with examples Stream dropWhile() method in Java with examples Stream iterate(T,Predicate,UnaryOperator) method in Java with examples Stream takeWhile() method in Java with examples 1
- Stream.Builder add() method in Java Stream.Builder accept() method in Java LongStream.Builder build() in Java Stream.Builder build() in Java
- Generate Infinite Stream of Integers in Java IntStream codePoints() method in Java with Examples Program to convert IntStream to String in Java Java Program to convert Character Array to IntStream Program to convert St
- IntStream.Builder accept() method in Java IntStream.Builder build() in Java with Examples IntStream.Builder add() method in Java
- LongStream.Builder add(long t) in Java LongStream.Builder accept() method in Java LongStream mapToInt() in Java with Examples LongStream reduce(long identity, LongBinaryOperator op) in Java with Examples LongStream red
- LongStream.Builder add(long t) in Java LongStream.Builder accept() method in Java LongStream.Builder build() in Java
- Generate Infinite Stream of Double in Java DoubleStream mapToObj() in Java DoubleStream.Builder accept() method in Java DoubleStream.Builder add(double t) in Java with Examples DoubleStream boxed() in Java with Example
- DoubleStream.Builder accept() method in Java DoubleStream.Builder add(double t) in Java with Examples DoubleStream.Builder build() in Java
- Collectors collectingAndThen() method in Java with Examples Collectors toMap() method in Java with Examples Collectors partitioningBy() method in Java Collectors toList() method in Java with Examples Java Stream Coll
- 10 Ways to Create a Stream in Java
- How to print elements of a Stream in Java 8
- Program to Iterate over a Stream with Indices in Java 8
- How to get ArrayList from Stream in Java 8
- 10 Ways to Create a Stream in Java Reverse elements of a Parallel Stream in Java How to get ArrayList from Stream in Java 8 Generate Infinite Stream of Double in Java Generate Infinite Stream of Integers in Java
Important Keywords
C++ vs Java
- What are C++ features missing in Java?
- Comparison of static keyword in C++ and Java
- Comparison of Exception Handling in C++ and Java
- Comparison of Inheritance in C++ and Java
- How does default virtual behavior differ in C++ and Java ?
- Foreach in C++ and Java
- C/C++ Pointers vs Java References
- Comparison of boolean data type in C++ and Java
- Floating Point Operations & Associativity in C, C++ and Java
Methods in Java
- Methods in Java
- How are parameters passed in Java?
- Returning Multiple values in Java
- Throwable fillInStackTrace() method in Java
- Valid variants of main() in Java
- Variable Arguments (Varargs) in Java
- Overloading in Java
- Different ways of Method Overloading in Java
- Method overloading and null error in Java
- Method Overloading with Autoboxing and Widening in Java
- Method Overloading and Ambiguity in Varargs in Java
- GFact 48 Overloading main() in Java
- Overriding equals method in Java
- Overriding toString() in Java
- Private and final methods in Java
- Java is Strictly Pass by Value!
- Clone() method in Java
- Remote Method Invocation in Java
- Passing and Returning Objects in Java
- Date after() method in Java
- System.exit() in Java
Constructors
- Constructors in Java
- Default constructor in Java
- Assigning values to static final variables in Java
- Copy Constructor in Java
- Constructor Chaining In Java with Examples
- Private Constructors and Singleton Classes in Java
- Java Interview Questions on Constructors
- Singleton Class in Java
- Constructor Overloading in Java
- Output of Java Programs Set 14 (Constructors)
Exception Handling
- Exceptions in Java
- Understanding OutOfMemoryError Exception in Java
- 3 Different ways to print Exception messages in Java
- Flow control in try catch finally in Java
- Types of Exception in Java with Examples
- Catching base and derived classes as exceptions
- Checked vs Unchecked Exceptions in Java
- throw and throws in Java
- User-defined Custom Exception in Java
- Infinity or Exception in Java when divide by 0?
- Multicatch in Java
- Chained Exceptions in Java
- Null Pointer Exception In Java
- Output of Java program Set 12(Exception Handling)
Interfaces and Abstract Classes
- Interfaces in Java
- Access specifier of methods in interfaces
- Access specifiers for classes or interfaces in Java
- Abstract Classes in Java
- Difference between Abstract Class and Interface in Java
- Comparator Interface in Java with Examples
- Java Interface methods
- Nested Interface in Java
- Nested Classes in Java
- Inner class in java
- Local Inner Class in Java
- Anonymous Inner Class in Java
- Functional Interfaces In Java
- Marker interface in Java
- Java Abstract Class and Interface
- Output of Java program Set 15 (Inner Classes)
- Static method in Interface in Java
- Function Interface in Java with Examples
- Apache POI Introduction
- Apache POI Getting Started
- Reading and Writing data to excel file using Apache POI
- Creating Sheets in Excel File in Java using Apache POI
- Creating a Cell at specific position in Excel file using Java
- Opening Existing Excel sheet in Java using Apache POI
Java Packages
Collection in Java
- Collections in Java
- AbstractCollection in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples Java.util.Collections.frequency() in Java with Examples Java.util.Collections.rotate() Method in Java with Examples Java.util.Collections.frequency() in Java
- Iterators in Java
- Convert an Iterable to Collection in Java
- How to use Iterator in Java?
- Iterator vs Foreach In Java
- Retrieving Elements from Collection in Java (For-each, Iterator, ListIterator & EnumerationIterator)
- Creating Sequential Stream from an Iterator in Java
- Output of Java programs Set 13 (Collections)
- Double Brace Initialization in Java
- List Interface in Java with Examples
- AbstractList in Java with Examples
- AbstractSequentialList in Java with Examples
- ArrayList in Java
- LinkedList in Java
- Immutable List in Java
- CopyOnWriteArrayList in java
- Custom ArrayList in Java
- Java Collection Difference between Synchronized ArrayList and CopyOnWriteArrayList
- Queue Interface In Java
- AbstractQueue in Java with Examples
- ArrayBlockingQueue Class in Java
- ConcurrentLinkedQueue in Java with Examples
- LinkedBlockingQueue Class in Java
- LinkedTransferQueue in Java with Examples
- PriorityBlockingQueue Class in Java
- Deque interface in Java with Example
- ArrayDeque in Java
- ConcurrentLinkedDeque in Java with Examples
- LinkedBlockingDeque in Java with Examples
- Set in Java
- AbstractSet Class in Java with Examples
- EnumSet in Java
- HashSet in Java
- TreeSet in Java
- ConcurrentSkipListSet in Java with Examples
- CopyOnWriteArraySet in java
- LinkedHashSet in Java with Examples
- Internal working of Set/HashSet in Java
- Merge two sets in Java
- Convert HashSet to TreeSet in Java Difference and similarities between HashSet, LinkedHashSet and TreeSet in Java LinkedHashMap and LinkedHashSet in Java Difference between ArrayList and HashSet in Java Difference Betw
- Map Interface in Java
- EnumMap class in Java
- HashMap in Java
- SortedMap Interface in Java with Examples
- WeakHashMap class in Java
- Immutable Map in Java
- LinkedHashMap in Java
- IdentityHashMap class in Java
- Java.util.Dictionary Class in Java
- ConcurrentHashMap in java
- Internal Working of HashMap in Java
- Traverse through a HashMap in Java
- Program to Convert HashMap to TreeMap in Java
- How to Clone a Map in Java ArrayList vs. HashMap in Java How to create a TreeMap in reverse order in Java How to check if a key exists in a HashMap in Java Difference between HashMap and HashSetv Remove an Entr
- Hashtable in Java
- Stack Class in Java
- Java.util.Vector Class in Java
Collection Interview FAQ’s
- Vector vs ArrayList in Java
- ArrayList vs LinkedList in Java
- Comparable vs Comparator in Java
- Differences between TreeMap, HashMap and LinkedHashMap in Java
- Differences between HashMap and HashTable in Java
- Hashmap vs WeakHashMap in Java
- Synchronization of ArrayList in Java
- ArrayList and LinkedList remove() methods in Java with Examples
- How to remove an element from ArrayList in Java?
Java.nio
- IntBuffer asReadOnlyBuffer() method in Java IntBuffer compareTo() method in Java IntBuffer duplicate() method in Java with Examples IntBuffer array() method in Java IntBuffer compact() method in Java IntBuffer
- FloatBuffer compareTo() method in Java With Examples FloatBuffer allocate() method in Java With Examples FloatBuffer compact() method in Java With Examples FloatBuffer arrayOffset() method in Java With Examples FloatBu
- DoubleBuffer wrap() method in Java with Examples DoubleBuffer arrayOffset() method in Java With Examples DoubleBuffer hasArray() method in Java with Examples DoubleBuffer put() methods in Java with Examples Set 1 Dou
- ShortBuffer equals() method in Java with Examples ShortBuffer order() Method in Java with Examples ShortBuffer toString() method in Java with Examples ShortBuffer slice() method in Java with Examples ShortBuffer alloca
- ByteBuffer arrayOffset() method in Java with Examples ByteBuffer equals() method in Java with Examples ByteBuffer asShortBuffer() method in Java with Examples ByteBuffer compact() method in Java with Examples ByteBuffe
- CharBuffer equals() method in Java CharBuffer put() methods in Java CharBuffer asReadOnlyBuffer() method in Java CharBuffer hasArray() method in Java CharBuffer array() method in Java CharBuffer arrayOffset() m
Java.Security
- Java Signature getAlgorithm() method with Examples Java Signature getProvider() method with Examples Java Signature toString() method with Examples Java Signature sign() method with Examples Java Signature getInstance(
- SecureRandom getInstance() method in Java with Examples SecureRandom generateSeed() method in Java with Examples SecureRandom getAlgorithm() method in Java with Examples SecureRandom getProvider() method in Java with Examples
- KeyPairGenerator genKeyPair() method in Java with Examples KeyPairGenerator generateKeyPair() method in Java with Examples KeyPairGenerator getInstance() method in Java with Examples KeyPairGenerator getProvider() method in Ja
- KeyFactory getAlgorithm() method in Java with Examples KeyFactory generatePublic() method in Java with Examples KeyFactory generatePrivate() method in Java with Examples
- AlgorithmParameterGenerator getProvider() method in Java with Examples AlgorithmParameterGenerator getAlgorithm() method in Java with Examples AlgorithmParameterGenerator generateParameters() method in Java with Examples
- Provider elements() method in Java with Examples Provider entrySet() method in Java with Examples Provider get() method in Java with Examples Provider getInfo() method in Java with Examples Provider getName() method in
Multithreading
- Multithreading in Java
- Lifecycle and States of a Thread in Java
- Main thread in Java
- Java Concurrency – yield(), sleep() and join() methods
- Inter-thread Communication in Java
- What does start() function do in multithreading in Java?
- Java Thread Priority in Multithreading
- Joining Threads in Java
- Naming a thread and fetching name of current thread in Java
- Synchronized in Java
- Method and Block Synchronization in Java
- Producer-Consumer solution using threads in Java
- Thread Pools in Java
- Semaphore in Java
- Java.util.concurrent.Semaphore class in Java
- CountDownLatch in Java
- Deadlock in Java Multithreading
- Daemon thread in Java
- Reentrant Lock in Java
- Java.util.concurrent.CyclicBarrier in Java
- Callable and Future in Java
Garbage Collection
- Garbage Collection in Java
- How to make object eligible for garbage collection in Java?
- Mark-and-Sweep: Garbage Collection Algorithm
- Island of Isolation in Java
- Automatic Resource Management in Java try with resource statements
- Output of Java programs Set 10 (Garbage Collection)
- Iterator vs Collection in Java
Wrapper Classes
Reflection in Java
- Reflection in Java
- Method class isSynthetic() method in Java Method Class getAnnotatedReturnType() method in Java Method Class getParameterAnnotations() method in Java Method Class getDeclaringClass() method in Java Method Class
- Reflection Array Class in Java
- util.Arrays vs reflect.Array in Java with Examples
- new operator vs newInstance() method in Java
- instanceof operator vs isInstance() method in Java
File Handling
- Java.io.File Class in Java
- Different ways of Reading a text file in Java
- File Permissions in Java
- Moving a file from one directory to another using Java
- Copying file using FileStreams in Java
- Delete a file using Java
- Java program to delete duplicate lines in text file
- Java program to merge two files alternatively into third file
- Java program to delete certain text from a file
- Check if a File is hidden in Java
- Redirecting System.out.println() output to a file in Java
Java Tuple
- JavaTuples Introduction
- Unit Class in JavaTuples
- Pair Class in JavaTuples
- Triplet Class in JavaTuples
- Quartet Class in JavaTuples
- Quintet Class in JavaTuples
- Sextet Class in JavaTuples
- Septet Class in JavaTuples
- Octet Class in JavaTuples
- Ennead Class in JavaTuples
- Decade Class in JavaTuples
- LabelValue Class in JavaTuples
- KeyValue Class in JavaTuples
- Implement Pair Class with Unit Class in Java using JavaTuples
- Implement Quartet Class with Triplet Class in Java using JavaTuples
- Implement Triplet Class with Pair Class in Java using JavaTuples
- Implement Decade Class from Ennead Class in Java using JavaTuples
- Implement Ennead Class from Octet Class in Java using JavaTuples
- Implement Septet Class from Sextet Class in Java using JavaTuples
- Implement Octet Class from Septet Class in Java using JavaTuples
- Implement Sextet Class from Quintet Class in Java using JavaTuples
- Implement Quintet Class with Quartet Class in Java using JavaTuples
Useful and/or Advanced Features
Image Processing
- Image Processing in Java Set 1 (Read and Write)
- Image Processing In Java Set 2 (Get and set Pixels)
- Image Processing in Java Set 3 (Colored image to greyscale image conversion)
- Image Processing in Java Set 4 (Colored image to Negative image conversion)
- Image Processing in Java Set 5 (Colored to Red Green Blue Image Conversion)
- Image Procesing in Java Set 6 (Colored image to Sepia image conversion)
- Image Processing in Java Set 7 (Creating a random pixel image)
- Image Processing in Java Set 8 (Creating mirror image)
- Image Processing in Java Set 9 ( Face Detection )
- Image Processing in Java Set 10 ( Watermarking an image )
- Image Processing in Java Set 11 (Changing orientation of image)
- Image Processing in Java Set 12 ( Contrast Enhancement )
- Image Processing using OpenCV in Java Set 13 (Brightness Enhancement)
- Image Processing using OpenCV in Java Set 14 ( Sharpness Enhancement )
- Image Processing in Java Set 14 ( Comparison of two images )
- Compressing and Decompressing files in Java
Networking in Java
- Socket Programming in Java
- Introducing Threads in Socket Programming in Java
- URL class in Java with Examples
- Java.net.HttpURLConnection Class in Java
- Reading from a URL using URLConnection Class
- Networking in Java Set 1 (Java.net.InetAddress class)
- MD2 Hash In Java
- SHA-1 Hash
- SHA-224 Hash In Java
- SHA-256 Hash in Java
- SHA-384 Hash In Java
- SHA-512 Hash In Java
Java.Time Package
- Java Clock tickMinutes() method in Java with Examples Java Clock withZone() method in Java with Examples Clock system() Method in Java with Examples Clock tick() Method in Java with Examples Clock tickSeconds() method
- Duration equals(Duration) method in Java with Examples Duration toHours() method in Java with Examples Duration ofSeconds(long, long) method in Java with Examples Duration get(TemporalUnit) method in Java with Examples
- Instant now() Method in Java with Examples Instant with() Method in Java with Examples Instant query() Method in Java with Examples Instant until() Method in Java with Examples Instant ofEpochSecond() Method in Java wi
- LocalDate until(ChronoLocalDate) Method in Java with Examples LocalDate until(Temporal,TemporalUnit) Method in Java with Examples LocalDate now() Method in Java with Examples LocalDate now() Method in Java with Examples
- LocalDateTime range() method in Java with Examples LocalDateTime until() Method in Java with Examples LocalDateTime now() Method in Java with Examples LocalDateTime with() Method in Java with Examples LocalDateTime que
- LocalTime range() method in Java with Examples LocalTime until() Method in Java with Examples LocalTime with() Method in Java with Examples LocalTime query() Method in Java with Examples LocalTime parse() method in Jav
- MonthDay range() method in Java with Examples MonthDay isValidYear() Method in Java with Examples MonthDay isBefore() Method in Java with Examples MonthDay isSupported() Method in Java with Examples MonthDay isAfter()
- Period withMonths() method in Java with Examples Period withYears() method in Java with Examples Period withDays() method in Java with Examples Period toTotalMonths() method in Java with Examples Period ofDays() method
- Year parse(CharSequence,DateTimeFormatter) method in Java with Examples Year parse(CharSequence) method in Java with Examples Year plus(TemporalAmount) method in Java with Examples Year isSupported(TemporalField) Method in Jav
- YearMonth parse(CharSequence,DateTimeFormatter) method in Java with Examples YearMonth parse(CharSequence) method in Java with Examples YearMonth isSupported(TemporalField) method in Java with Examples YearMonth isSupported(T
- ZonedDateTime until() Method in Java with Examples ZonedDateTime of() Method in Java with Examples ZonedDateTime now() Method in Java with Examples ZonedDateTime ofStrict() Method in Java with Examples ZonedDateTime wi
Java.Lang Package
- Java.lang.Boolean Class in Java
- Java.Lang.Byte class in Java
- Java.lang.Character Class in Java
- Java.lang.Character.Subset Class in Java
- Java.lang.Character.UnicodeBlock Class in Java
- Java.lang.Class class in Java Set 1
- Java.lang.Class class in Java Set 2
- Java.lang.Compiler Class in Java
- Java.Lang.Double class in Java
- Java.lang.Enum Class in Java
- Java.Lang.Float class in Java
- Java.lang.InheritableThreadLocal Class with Examples
- Java.lang.Integer class in Java
- Java.Lang.Long class in Java
- Java.lang.Math Class in Java Set 1
- Java.lang.Math Class in Java Set 2
- Java.lang.Number Class in Java
- Object class in Java
- Java.lang.Package class in Java
- Java.lang.Process class in Java
- Java.lang.ProcessBuilder class in Java
- Java.lang.Runtime class in Java
- Java.Lang.Short class in Java
- Java.lang.StackTraceElement class in Java
- Java.lang.StrictMath class in Java Set 1
- Java.lang.StrictMath class in Java Set 2
- String class in Java Set 1
- Java.lang.String class in Java Set 2
- StringBuffer class in Java
- StringBuilder Class in Java with Examples
- Java.lang.System class in Java
- Java.lang.Thread class in Java
- Java.lang.ThreadGroup class in Java
- Java.lang.ThreadLocal class in Java
- Throwable setStackTrace() method in Java with Examples
- Java.lang.Void Class in Java