Character Class Operations in Python

Rajendra Dharmkar
Updated on 28-Aug-2025 11:09:56

2K+ Views

Character class operations in Python's regular expressions allow us to define set of characters we want to match. Instead of searching for one specific character, we can search for any character within that set. A character class in regex is written using square brackets []. It defines a group of characters where any character from the group can match a part of the string. Commonly Used Character Classes in Python (re module) Regular expressions use both normal and special characters. Normal characters like 'A', 'a', or '0' match themselves. So, "last" (a sequence of characters) matches the string 'last'. Some characters, ... Read More

Split a String on a Fixed Character Sequence in Java

Aishwarya Naglot
Updated on 28-Aug-2025 10:31:48

660 Views

In this article, we will learn how to split a string on a fixed character sequence in Java. We have multiple ways to split a string in Java. Some of them are as follows: Using the split() method of the String class. Using the substring() method of the String class. Using the StringTokenizer class. Let's discuss each of them in detail one by one. Using the split() method of the String class The split() method of the String class accepts a delimiter (in the form of a string), divides the current String into smaller strings based on the ... Read More

Create String from File Contents in Java

Aishwarya Naglot
Updated on 28-Aug-2025 10:30:07

248 Views

We can use the method below to read the contents of a file in Java: Using the java.util.Scanner class. Using the java.io.BufferedReader class. Using the java.nio.file.Files class. Using the Scanner class In Java, you can read the contents of a file in several ways. One way is to read it into a string using the java.util.Scanner class, to do so, follow the steps below: Instantiate the Scanner class, with the path of the file to be read, as a parameter to its constructor. Create an empty String buffer. Start a while loop with a condition, if the ... Read More

Extract Words Starting with a Vowel of Length N in Java

Aishwarya Naglot
Updated on 28-Aug-2025 09:38:37

2K+ Views

In this article, we will learn to extract all the words that start with a vowel and have a length equal to n from a given text file or string in Java. We can solve this problem using the following ways: Using the split() method of the String class. Using the StringTokenizer class. Using Regular Expressions. Using the split() method of the String class To extract all the words that start with a vowel and have a length equal to n from a given text file or string in Java, we can use the following steps: The ... Read More

Read Python Dictionary Using C++

Samual Sam
Updated on 28-Aug-2025 09:29:08

542 Views

A dictionary in Python is a collection of key-value pairs where each key must be unique. The lists, which are indexed by numbers, are accessed using keys that can be immutable types, strings, numbers, or tuples. Lists cannot be used as keys because they can be modified. Dictionaries are created using {}, and key-value pairs are added with commas. We can store, retrieve, and delete values using their keys. Using the list() returns all keys, while sorting them. To check if a key exists, we can use the in keyword. If a key is replaced, then its old value is replaced. ... Read More

C++ Program to Implement Doubly Linked List

Nishu Kumari
Updated on 26-Aug-2025 19:00:20

39K+ Views

A Doubly Linked List is a data structure made up of nodes created using self-referential structures. Each node contains three parts, namely the data, a pointer to the next node, and a pointer to the previous node. Also, the doubly linked list can be traversed in both forward and backward directions. Only the reference to the first node is required to access the whole linked list. This is known as the head. The last node in the list points to nothing, so it stores NULL in that part. In this article, we will write a C++ program to ... Read More

Compare Elements in a Collection in Java

Aishwarya Naglot
Updated on 26-Aug-2025 17:18:53

810 Views

In Java, the Collection framework provides an architecture to store and manipulate a group of objects. Collections support operations such as searching, sorting, insertion, manipulation, and deletion. In this article, we will learn how to compare elements in a collection in Java using different approaches. Before learning about the methods, let us understand the problem with the help of the following input-output scenarios: Scenario 1 Input: ["Java", "Python", "JavaScript", "C++"] Element to Compare: "Java" Output: Java is equal to Java Python is not equal to Java JavaScript is not equal to Java C++ is not equal to ... Read More

Convert List of Strings to Comma-Separated String in Java

Aishwarya Naglot
Updated on 26-Aug-2025 16:44:22

805 Views

A list is a collection in Java which is used for storing group of elements. It is an ordered collection which also allows to store duplicate elements. A String is a sequence of characters which is used for representing text in Java. Here, in this article, we are given a list of strings, we have to convert it into a comma-separated string in Java using different approaches. To understand this problem, consider the following input-output scenarios: Scenario 1 Input: ["Apple", "Banana", "Mango", "Orange"] Output: Apple, Banana, Mango, Orange Scenario 2 Input: ["Red", "Green", "Blue"] Output: ... Read More

Order of Execution of Non-Static Blocks in Java

Alshifa Hasnain
Updated on 26-Aug-2025 16:34:46

3K+ Views

In Java, non-static blocks run before the constructor whenever an object is created. If multiple non-static blocks exist, they execute in the order they appear in the class, followed by the constructor. In this article, we will understand this order of execution with the help of examples. What Are Non-Static Blocks in Java? The Non-static blocks are class-level blocks which don't contain a prototype. A non-static block must perform any logic whenever an object is instantiated, regardless of the constructor. The Non-static blocks are automatically called by the JVM for every object creation in the Java stack area. We can ... Read More

Define Constructor Inside an Interface in Java

Maruthi Krishna
Updated on 26-Aug-2025 16:30:22

8K+ Views

Interfaces in Java are used for defining a contract that classes can implement. They can contain method signatures, default methods, static methods, and constants. we must implement the methods defined in the interface in the implementing class. Can we define a constructor inside an interface in Java? No, constructors cannot be defined inside an interface in Java. Constructors are special methods that are used to initialize objects of a class, and since interfaces cannot be instantiated, they do not have constructors. Why can constructors not be defined in an interface? There are several reasons why constructors cannot be defined ... Read More

Advertisements