Maruthi Krishna has Published 870 Articles

What is the return type of a Constructor in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 21-Aug-2025 12:35:03

6K+ Views

A Constructor in Java is similar to a method, and it is invoked at the time of creating an object of the class, it is generally used to initialize the instance variables of a class. The constructors have same name as their class. The main purpose of a constructor is ... Read More

Can we call a method on \"this\" keyword from a constructor in java?

Maruthi Krishna

Maruthi Krishna

Updated on 04-Aug-2025 13:32:14

6K+ Views

The “this" keyword in Java is used as a reference to the current object within an instance method or a constructor. Using this, you can refer to the members of a class, such as constructors, variables, and methods. Calling a Method using "this" From a Constructor Yes, as mentioned, we ... Read More

How to check multiple regex patterns against an input? Using Java.

Maruthi Krishna

Maruthi Krishna

Updated on 15-Jul-2025 17:58:40

5K+ Views

In Java, the strings that are used to find the pattern are known as regular expressions. In this article, we will learn to check multiple regex patterns against an input, and it can be done by using 2 approaches. Using Metacharacter ... Read More

Posix character classes p{ASCII} Java regex.

Maruthi Krishna

Maruthi Krishna

Updated on 18-Jun-2025 18:55:44

831 Views

In this article, we will learn about the p{ASCII} of the POSIX character class in Java regex. What is \p{ASCII}? In Java regex, \p{ASCII} POSIX character class matches any of the characters that fall within ASCII. ASCII (American Standard Code for Information Interchange) defines a character encoding standard consisting of ... Read More

Posix character classes p{Digit} Java regex

Maruthi Krishna

Maruthi Krishna

Updated on 17-Jun-2025 16:28:12

463 Views

In this article, we will learn about the POSIX character classes p{Digit} Java regex. First, will know about \p{Digit} and the use of \p{Digit} along with examples. What is \p{Digit}? In Java regex, the \p{Digit} is a POSIX (Portable Operating System Interface) character class in Java regular expressions that matches any decimal digit ... Read More

How to remove an element from ArrayList or, LinkedList in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 16-Jun-2025 19:03:21

845 Views

The ArrayList and LinkedList classes implement the List interface of the java.util package. This interface provided two variants of the remove() method to remove particular elements, as shown below - Using remove(int index) ... Read More

How to parse for words in a string for a specific word in java?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Jun-2025 15:21:38

976 Views

In this article, we will learn how to parse for words in a string for a specific word in Java,  i.e., we need to check if a specific word exists in a string, and if it does, we will parse the string to find that word. There are various methods ... Read More

How to overwrite a line in a .txt file using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 12-May-2025 19:07:46

20K+ Views

The given task is to overwrite a line in a .txt file with new content. Assume we have a .txt file with the following content - Line 1: Hello World Line 2: This is a test file. Line 3: This line will be overwritten. Line 4: Goodbye! We want ... Read More

What happens when we try to add a duplicate key into a HashMap object in java?

Maruthi Krishna

Maruthi Krishna

Updated on 08-May-2025 11:52:38

4K+ Views

No, HashMap does not allow duplicate keys. The HashMap is a class that implements the Map interface. It is based on the Hash table. It is used to store key-value pairs. It allows null keys and values, but it does not allow duplicate keys. You can store key-value pairs in ... Read More

Reading data from keyboard using console class in Java

Maruthi Krishna

Maruthi Krishna

Updated on 08-May-2025 10:00:29

830 Views

The Console class is part of the Java.io package and is used to read input from the keyboard or user and write output to the console. Unlike Scanner, the Console class provides methods to read text and passwords. If you read a password using the Console class, it will not be displayed to the ... Read More

Advertisements