java

java

Write a love calculator program in Java

In this tutorial, we will learn how to create one love calculator program. This program will take two names as inputs, calculates the percentage and prints it out. How the program is calculating the percentage, I am explaining below.

Read
java

Introduction to Java JShell or Java Shell tool

Java JShell was introduced in Java 9. It is an interactive tool for learning Java. It is a Read-Evaluate-Print Loop (REPL) that can be used to evaluate different Java expressions on the terminal.

Read
java

Java example program to left shift an array

In this tutorial, we will learn how to left shift an array in Java . Left shifting by one means the array elements will be moved by one position to left and the leftmost element will be moved to end.

Read
java

Java arraylist set method example

set method is used to replace one element in an ArrayList in Java. In this tutorial, I will show you how to use set method with one example.

Read
java

Java String concat example

concat() method is used to join two strings. It concatenates one string to the end of another string. This method is defined as below :.

Read
java

Java LinkedList poll, pollFirst and pollLast example

Java provides a utility class called LinkedList to create linked lists. Unlike any other programming languages like C, we can create one Linked list easily using this class.

Read
java

Java peek(), peekFirst() and peekLast() explanation with examples

Using LinkedList class, we can create one linked list in Java. This class provides a lot of different methods to operate on the elements of the linked list. In this tutorial, we will check three inbuilt methods peek(), peekFirst() and peekLast() of the LinkedList class.

Read
java

How to add elements to a Java vector using index

Vector is a good replacement of array in Java if you want to add elements dynamically. We can add elements dynamically to a vector and it will increase its size, unlike arrays. Previously we have learned different examples of vectors like [how to create vectors](https://www.codevscolor.com/java-print-vector-contents), how to [add elements to a vector](https://www.codevscolor.com/add-elements-to-java-vector-using-index) and how to [clear a vector](https://www.codevscolor.com/how-to-clear-vector-in-java). In this tutorial, we will learn how to add elements to a vector in a specific position, i.e. using index numbers.

Read
java

How to compare Substrings in Java using regionMatches

Sometimes we need to compare two substrings in different string in Java. We can do that by comparing each character one by one of both strings but Java String class comes with a built-in method called regionMatches to make this task easier.

Read
java

Java program to print all contents of a vector using enumeration

In this tutorial, we will learn how to use enumeration to iterate over a vector in Java. Our program will first take the inputs for the vector from the user, it will then print out the inputs using enumeration.

Read