Similar to 'java.util.Random' or 'Math.random()', ThreadLocalRandom is also a Random number generator in Java. With multithreading environment, it is better to use 'ThreadLocalRandom' instead of above two.
ReadIn this tutorial, we will learn how to convert string to byte array and byte array back to a string. Converting a string to a byte array is useful in many cases like IO operations.
ReadSortedSet is a interface that extends 'Set'. You can do all set operations on its elements. Only difference is that the elements of SortedSet implemented classes are ordered. By default, all the elements are sorted in natural order.
ReadThe problem is to rotate each words of a String. For this we need to extract all words from the string. Following steps are used in this program to reverse each words :.
ReadIn this tutorial, we will learn how to convert one octal number to binary in Java. But before that, let's check what is octal number and what is its relation with binary.
ReadIn this tutorial, we will learn two most commonly used Java System functions - System.nanoTime and System.currentTimeMillis(). Both are time related functions, i.e. to get a time from the system (not the current time ).
ReadIn this tutorial, we will print out all files and folders of a directory in sorted order using Java. To run this program, you will have to change the directory name defined inside 'main' method. order
ReadJava has inbuilt methods to find square root and cube root of a number . Both of these methods are already included in the 'Math' module.
ReadUsing 'FileReader' class, we can read contents of a file. Using this class, we can read the contents as a stream of characters. In this tutorial, I will show you one simple example to use 'FileReader' class in Java .
ReadTo create a object of 'FileInputStream', we have three different ways. (i.e. three different constructors available). We can create by passing a file name , i.e. full path of the file (e.g. C://filename.txt ) or by passing a 'File' object or by passing a 'FileDescriptor' . In this example, I will show you by passing a 'File' object to the constructor.
Read