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).
Recursion is referred to a programming style where a method invokes itself repeatedly until a certain predefined condition is met. Such method calls are also called recursive methods.
Java naming conventions are sort of guidelines which application programmers are expected to follow to produce a consistent and readable code throughout the application. If teams do not not follow these conventions, they may collectively write an application code which is hard to read and difficult to understand. Java heavily uses CamelCase notations for naming […]
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 modifier ensures that all floating-point operations across different JVMs will provide consistent and same result as predicted by IEEE 754.
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 exception handling, throw keyword is used to explicitly throw an exception from a method or constructor. And throws keyword is used declare the list of exceptions which may be thrown by that method or constructor. 1. Java throw keyword 1.1. Syntax To throw an exception from a method or constructor, use throw keyword […]
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 keyword is used to create assertions in Java, which enables us to test the assumptions about our program. For example, an assertion may be to make sure that an employee’s age is positive number. Each assertion contains a boolean expression that you believe will be true when the assertion executes. If it is […]
Java abstract keyword can be used with classes and methods; but not with variables. abstract is non-access modifier which helps in achieving abstraction.
Java application code is normally executed sequentially from top to bottom in the order that the code appears. To apply business logic, we may need to execute code on conditional basis. Control flow statements helps in this conditional execution of code blocks. All control flow statements are associated with a business condition – when true, […]
Java CopyOnWriteArraySet example. This class is a thread-safe variant of HashSet which uses a underlying CopyOnWriteArrayList for all of its operations.
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 was created. This helps in […]
Java TransferQueue is a concurrent blocking queue implementation in which producers may wait for receipt of messages by consumers. LinkedTransferQueue class is an implementation of TransferQueue in Java. TransferQueue may be useful for example in message passing applications in which producers sometimes (using method transfer()) await receipt of elements by consumers invoking take or poll, […]
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 the shortest time. New elements […]
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 example. PriorityQueue class is a queue data structure implementation in which objects are processed based on their priority.
Java Spliterator interface is an internal iterator that breaks the stream into the smaller parts. These smaller parts can be processed in parallel. In real life programming, we may never need to use Spliterator directly. Under normal operations, it will behave exactly same as Java Iterator. The Java collection classes provide default stream() and parallelStream() […]