java

java

Java program to print an identity matrix

In this tutorial, we will learn how to print one identity matrix using Java programming language. Identity matrix is a matrix whose diagonal elements are 1. Diagonal elements starting from top left to right end should be 1 and other elements are 0 of that matrix.

Read
java

Java LinkedHashMap : create,iterate through a LinkedHashMap

LinkedHashMap is hash table and linked list implementation of the Map interface with predictable iteration order. It maintains a doubly linked list through all entries. The iteration order is normally the same order in which the keys are inserted into the map.

Read
java

Java program to read and print a two dimensional array

In this tutorial, we will learn how to read elements of a two-dimensional array and print out the result. We will first read the row and column number from the user and then we will read all elements one by one using a loop.

Read
java

Java 8 example to convert a string to integer stream (IntStream)

In this tutorial, we will learn how to convert a string to IntStream. We will use chars() method to convert a string to IntStream. To print out the result of the IntStream, we will use Stream.forEach method. Then we will pass one lambda expression to print out the characters.

Read
java

How to override toString method to print contents of a object in Java

To print the contents of an object, we need to override toString() method of that object. In this tutorial we will learn how to override toString() method of an object and what are the benifits of doing it.

Read
java

Implement a Queue Data Structure in Java using Linked List

The Queue is an interface in Java which extends Collection interface. In this tutorial, we will learn how to use Queue to implement a Queue data structure in Java. Queue is a FIFO or First in first out data structure. That means it will always insert an element to the end of the list and remove an element from the beginning of the list.

Read
java

Java program to print random uppercase letter in a string

In this tutorial, we will learn how to print random uppercase letter from a String in Java. To achieve that, we will first create one random number . The size of the random number is maximum length of the string. After that, we will pick the character for that position from the String and finally, we will print the uppercase version of the character. The java program is as below :.

Read
java

Java program to swap first and last character of a string

In this tutorial, we will learn how to swap the first and last character in Java. The user will enter one string, our program will swap the first and last character of that string and print out the result. Let's take a look at the program first :.

Read
java

Java program to find the total count of words in a string

In this tutorial, we will learn how to count the total number of words in a string in Java. The user will enter one string. Our program will count the total number of words in the string and print out the result.

Read
java

Java program to find the sublist in a list within range

In this tutorial, we will learn how to find one sublist of a list within a range. The user will enter the starting index and end index of the list. We will print out the sublist using this starting and ending index. Let's take a look at the Java program first :.

Read