Convert String to LocalDateTime in Java
Java LocalDateTime class represents an instant in local timeline i.e. without any timezone id. Learn to convert string to LocalDateTime.
“Core Java” is Sun’s term, used to refer to Java SE, the standard edition and a set of related technologies, like the Java VM, CORBA, etc. This is mostly to differentiate from others like Java ME or Java EE. “Core Java” is Oracle’s definition and refers to subset of Java SE technologies.
The Core Java technologies and application programming interfaces (APIs) are the foundation of the Java Platform, Standard Edition (Java SE). They are used in all classes of Java programming, from desktop applications to Java EE applications.
Java LocalDateTime class represents an instant in local timeline i.e. without any timezone id. Learn to convert string to LocalDateTime.
Java LocalDate class represents a calendar date without time (hour/minute/seconds) and timezone information. Learn to convert a string to LocalDate object in Java.
Learn about the ZonedDateTime class in Java, how to create its instances and other use cases such as parsing, formatting and adding duration and periods.
Learn about the LocalDateTime class in Java, how to create its instances and other use cases such as parsing, formatting and adding duration and periods. 1. Overview java.time.LocalDateTime class, introduced in Java 8 Date Time API, represents a date and time object without a timezone often viewed as ‘year-month-day-hour-minute-second‘. It …
Learn to create and use the LocalTime class in Java. Learn how to create LocalTime, parse and format the LocalTime instances, including common operations such as adding or subtracting hours from a given time.
Learn about the LocalDate class in Java, how to create its instances and other use cases such as parsing, formatting and adding duration and periods.
Learn to create generic functional interfaces with and without type restrictions in Java. Learn to create specialized functional interfaces.
Learn to create Streams of primitives and objects in Java using some most popular ways. We will learn to create finite as well as infinite streams.
Learn to perform load and performance testing for a web application in this step by step JMeter tutorial. This Jmeter example is intended for beginners who are trying to use the Jmeter for the first time.
Learn to find the union of two arrays in Java using HashSet and Stream APIs with easy-to-understand Java examples.
Learn to find the intersection of two arrays in Java using HashSet and Stream API. An intersection contains the items present in both arrays.
The program arguments passed at launching the Java program are called command line arguments. While launching the program we can pass additional arguments (no limit of numbers of arguments).
Java instance initializers are the code blocks containing the instructions to run every time a new class instance is created in runtime.
Java naming conventions are sort of guidelines that application programmers are expected to follow to produce consistent and readable code throughout the application. If teams do not follow these conventions, they may collectively write an application code that is hard to read and difficult to understand. Always try to give …
this and super are reserved keywords in Java. this refer to current instance of a class while super refer to the parent class of that class where super keyword is used.
Java strictfp (enabled by default since Java 17) ensures that all floating-point operations will provide consistent results as predicted by IEEE 754 in all JVMs.
In this Java tutorial, learn about difference between final, finally and finalize in detail. In short, final is a keyword, finally is a block and finalize is a method. They have their own very specific purpose in Java programs.
In Java, the extends keyword is used for extending a class or interface; and the implements keyword is used for implementing the interfaces.
Java instanceof (type comparison operator) is used to test if a specified variable is an instance of the specified class or interface
In Java exception handling, throw keyword is used to explicitly throw an exception from a method or constructor. And throws keyword is used to declare the list of exceptions that may be thrown by that method or constructor. 1. Throw Let us learn basic things about throw keyword before going …
Java synchronized keyword marks a block or method a critical section. A critical section is where one and only one thread is executing at any given time.
Java try catch finally blocks helps in writing the application code which may throw exceptions in runtime and gives us chance to recover from the exception.
Java boolean keyword is used to declare a variable as a boolean type which represents only one of two possible values i.e. either true or false.
Java assert statements contain a boolean expression that must be true when the assertion executes. If it is not true, it will throw an AssertionError.
Java abstract keyword can be used with classes and methods; but not with variables. abstract is non-access modifier which helps in achieving abstraction.
In Java, control flow statements help in conditionally executing statements based on whether the evaluation result is true or false.
CopyOnWriteArraySet is a thread-safe Set in Java. It ensures safe concurrent access by creating a new copy of the internal array for each modification.
Java CopyOnWriteArrayList is a thread-safe variant of ArrayList in which all mutative operations (add, set, and so on) are implemented by making a fresh copy of the underlying array. It’s immutable snapshot style iterator method uses a reference to the state of the array at the point that the iterator …
In Java, the TransferQueue interface is a concurrent BlockingQueue implementation with support to support “synchronous message passing” between producers and consumers. The key feature of TransferQueue is the transfer() method that blocks until the message is handed off to a consumer. 1. TransferQueue Interface The TransferQueue is an interface in …
ArrayBlockingQueue class is Java concurrent and bounded blocking queue implementation backed by an array. It orders elements FIFO (first-in-first-out). The head of the ArrayBlockingQueue is that element that has been on the queue the longest time. The tail of the ArrayBlockingQueue is that element that has been on the queue …
Java PriorityBlockingQueue class is concurrent blocking queue data structure implementation in which objects are processed based on their priority. The “blocking” part of the name is added to imply the thread will block waiting until there’s an item available on the queue.
Java PriorityQueue is an unbounded Queue implementation that processes the items based on priorities. Custom ordering can be enforced with a Comparator.
Unlike traditional iterators, Spliterator is designed with parallelism in mind and mainly helps in parallel processing when the collection or stream has a large number of elements.
The Java ListIterator interface is a bidirectional iterator that iterates over the elements in both forward and backward directions.
Java Iterator interface is used to iterate over the elements of a Collection (List, Set or Map). The Iterator helps in retrieving the elements from the specified collection one by one and optionally performs operations over each element. Java Iterator was first introduced in Java 1.2 as a replacement of Enumerations. …
Java Comparator interface used to sort a array or list of objects based on custom order. Custom ordering of elements is imposed by implementing Comparator.compare() method in the objects.
Java Comparable interface is part of Collection Framework. Learn the purpose of Comparable interface and use it in different scenarios. 1. Comparable Interface 1.1. Why Implement Comparable? In Java, if we want to sort a List of elements then we can Collections.sort() method. It sorts the list items according to …
Java LinkedList class is doubly-linked list implementation of the List and Deque interfaces. It implements all optional list operations, and permits all elements (including null). Table of Contents 1. LinkedList Hierarchy 2. LinkedList Features 3. LinkedList Constructors 4. LinkedList Methods 5. LinkedList Example 6. LinkedList Usecases 7. LinkedList Performance 8. …
Java TreeSet class extends AbstractSet and implements NavigableSet interface. It is very similar to HashSet class, except it stores the element in sorted order.
Java LinkedHashSet class extends HashSet and implements Set interface. It is very very similar to HashSet class, except if offers the predictable iteration order.
Java HashSet class implements the Set interface, backed by a hash table(actually a HashMap instance). If does not offer any guarantees as to the iteration order, and allows null element.
Java Hashtable class is an implementation of hash table data structure. It is very much similar to HashMap but it is synchronized while HashMap is not.
Java TreeMap class stores key-value pairs very similar to the HashMap class. The difference is that TreeMap provides an efficient way to store key/value pairs in sorted order. The TreeMap class is a red-black tree-based NavigableMap implementation. This Java TreeMap tutorial will teach us about TreeMap class, methods, usecases, and …
LinkedHashMap in Java is used to store key-value pairs very similar to HashMap class. Difference is that LinkedHashMap maintains the order of elements inserted into it while HashMap is unordered. In this Java collection tutorial, we will learn about LinkedHashMap class, it’s methods, usecases and other important details. Table of …
Learn to create clone of a HashMap in Java. We will see the java programs to create shallow copy and deep copy of a HashMap. 1. Creating a Shallow Copy of Map We can create a shallow copy of a given HashMap in two ways. The first uses the clone() …
Learn to remove duplicate elements from an ArrayList using different techniques such as HashSet, LinkedHashSet, and using Java 8 stream.
Learn to find, count and remove duplicate elements from an array in Java using Streams, Map and Set from the Collections framework.
Java HashMap is not synchronized by default. Learn to use synchronized maps using Collections.synchronizedMap() and ConcurrentHashMap.
Learn merging two hashmaps in both cases – ignoring duplicate keys (overwrites the value) or handling duplicate keys. 1. Merge Two HashMaps Ignoring Duplicate Keys This one is a simple solution. Use firstMap.putAll(secondMap) method that copies all of the mappings from the secondMap to firstMap. As we know hashmap does …
Learn to compare two Java Maps for the equality of their entries, key and values, and find the Map differences using Guava’s MapDifference API.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.