java

Java program to convert a string to lowercase and uppercase

In this example, I will show you how to convert all characters of a string to uppercase or lowercase. First we will take the input string from the user using 'Scanner' class and then convert it to upper and lower case using following two methods :.

Read
java

Create Random int,float, boolean using ThreadLocalRandom in Java

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.

Read
java

Java program to convert string to byte array and byte array to string

In 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.

Read
java

SortedSet in Java explanation with Example

SortedSet 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.

Read
java

Java program to rotate each word in a string

The 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 :.

Read
java

Java program to convert octal to binary

In 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.

Read
java

Java System.nanoTime and System.currentTimeMillis

In 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 ).

Read
java

Java program to print all files and folders in a directory in sorted order

In 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

Read
java

Java program to find square root and cubic root of a number

Java has inbuilt methods to find square root and cube root of a number . Both of these methods are already included in the 'Math' module.

Read
java

Java program to read contents of a file using FileReader

Using '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 .

Read