String Methods Java

In Java programming language, a string is nothing but a sequence of characters. It is the most widely used object. Java String class has many methods that are used for various manipulations. It is immutable, meaning, its value cannot be changed. A string is equivalent to an array of characters. …

Read more

Constructor in Java

A constructor in Java is nothing but a special method that is executed during instance creation of a class. Whenever we create an object for the class, the java compiler calls the constructor of that class implicitly. We can use the constructor to initialize arguments for the object which we …

Read more

How to compile and run Java program

How to compile and run Java program – Let us see how to write, compile, and run a simple java program. We can either use a command prompt or any IDE like Eclipse to compile and run any Java program. In this tutorial, we will see both methods. Prerequisite We …

Read more

math.random Java

The math.random function in java is used for random number generation. This unique number is of type Double which is greater than 0.0 and less than 1.0. Each time this method returns a new random number when it is called. We can use this method to generate random unique passwords, …

Read more

Java string format

Java string format String.format() method in Java returns a formatted string value based on locale, format, and arguments passed. If we do not specify the locale, it takes the default locale from Locale.getDefault(). The extra arguments will be ignored if more arguments are passed. This method is similar to sprintf() …

Read more

HashMap Java

HashMap Java stores the data in the form of key-value pairs where the key data should be unique. We can access the values based on the corresponding key data. HashMap is present in Java’s Collection framework and is part of java.util package. It works on the principle of the Hashing …

Read more

Java Scanner

The Java Scanner class is used to get user input from different streams like user input, file, and the input string. This class is part of the java.util package. By using various in-built methods, it can read different types of input. Working of Scanner The scanner object reads the input …

Read more

What is Variable in Java

What is Variable in Java – Variables in Java are a memory location that holds a specific value. Before we use any variable, we need to declare it. Every variable is identified with a data type. We will cover data types in the next tutorial. Declaring a variable in Java …

Read more

ArrayList in Java

ArrayList in Java is the most commonly used data structure for creating a dynamic size array. It extends the Abstract class and implements the Java List interface. The main difference between array and ArrayList is that the array is static(we cannot add or remove elements) while ArrayList is dynamic(we can …

Read more

Translate ยป