Method Overloading and Type Promotion in Java

Shriansh Kumar
Updated on 21-Apr-2025 16:02:36

2K+ Views

Method overloading helps to create multiple methods with the same name to perform similar operations in different ways ( using different types of parameters). Automatic Type promotion or conversion in Java is a process in which the compiler automatically promotes a small-sized data type to a larger-sized data type. It is not possible to convert a larger size to a smaller size automatically. In method overloading, the overloaded method is called based on the arguments passed. Suppose we are calling an overloaded method, and the type of argument is not the exact match to the type defined in the method ... Read More

Convert String to Bytes in Python 3

Yaswanth Varma
Updated on 21-Apr-2025 15:59:38

405 Views

In Python, strings and bytes are two different types of data, Where the strings are the sequences of unicode characters used for text representation, While bytes are sequences of bytes used for binary data. Converting strings to bytes is used when we want to work with the raw binary data or perform low-level operations. This can be done by using the built-in encode method. Using Python encode() Method The Python encode() Method is used to convert the string into bytes object using the specified encoding format. Syntax Following is the syntax for Python encode() method ... Read More

Check if Multiple Strings Exist in Another String in Python

Yaswanth Varma
Updated on 21-Apr-2025 15:57:16

11K+ Views

While working with the strings, Checking if the string exists inside another string is a common task and can be achieved by using the in keyword. But, In this article we are going to see how to check if multiple strings exist in another string in Python. For example, checking the multiple strings: "TP", "WELCOME", exists in the string "WELCOME to TP". For achieving this, Python provides different methods including loops, any() and all(). Using Python any() Function The Python any() function returns true if any of the element of the given iterable (such as list, ... Read More

Check if a String is Empty in Python

Yaswanth Varma
Updated on 21-Apr-2025 15:54:00

4K+ Views

The strings are the fundamental data types that are used to store text. When working with the string, Checking if the string is empty or not is a common task. An empty string is nothing but the string with zero characters. There are various to check if a sting is empty, But choosing the elegant ways helps to improve the code readability. Let's dive into the article to learn more about it. Using if not my_string In Python, empty strings are considered as falsy, Which evaluates to false in a boolean content. So using not my_string returns true ... Read More

Remove Empty Strings from a List of Strings in Python

Yaswanth Varma
Updated on 21-Apr-2025 15:51:52

9K+ Views

The Lists in Python are used to store collections of items such as numbers, strings. While working with the list of strings, it is common to find a empty strings in the list. An empty string is nothing but a string value with zero length. Officially they are present as elements in the list, but does not hold any data and interfere in the operations like sorting, filtering. So, removing the empty strings is essential to ensure the list contains only valid values. For achieving this, Python provides the several ways. Let's dive into the article to learn ... Read More

Process Escape Sequences in a String in Python

Yaswanth Varma
Updated on 21-Apr-2025 15:45:58

3K+ Views

The escape sequences are the special characters that are used to represent the whitespace characters, quotes, backslashes or non-printable characters within the string. These sequences start with the backslash followed by the character, For example result in newline. However, in some cases we will come across the situations to process or even to ignore these situations. In this article we will learn how to process the escape sequences. Example Let's look at the following example, where we are going to consider the basic approach to process the escape sequences. str1 = "Hello\tEveryoneWelcome to TutorialsPoint" print(str1) ... Read More

Strip Spaces, Tabs, and Newlines Using Python Regular Expression

SaiKrishna Tavva
Updated on 21-Apr-2025 15:45:08

925 Views

Python regular expressions (regex) provide various ways to handle whitespaces, including spaces, tabs, and newline characters, which can be effectively stripped from strings using regex. This article will explain how to split a string on newline characters using different regular expressions, following are the various methods to achieve the present task. Using re.split(r"[]", text) Splitting on One or More Newlines Using Quantifier [+] Splitting on Newlines with Whitespace Using re.split(r"\s*", text) Using re.split(r"[]", text) The re.split() function splits a string wherever the specified regular expression pattern ... Read More

Run JAR File in Command Prompt

Maruthi Krishna
Updated on 21-Apr-2025 15:21:33

4K+ Views

A JAR file is like a ZIP file but for Java code. For the packaging of multiple class files, Java provides a file format known as JAR (Java Archive). Typically, a JAR file contains .class files, images, text files, and libraries in a single file that are required to execute the Java application or library. This file format is used to distribute application software and libraries in Java. All the predefined libraries are available in this format. If you have any library in JAR format, to use it in your application, you either need to place it in the current folder ... Read More

Can Enum Extend Any Class in Java

Maruthi Krishna
Updated on 21-Apr-2025 15:13:34

2K+ Views

If you’ve been coding in Java for some time, you might have wondered why you can't make an enum extend another class. It seems like it should, but Java won't let you. Let's break down why this happens Enumeration in Java Enumeration (enum) in Java is a user-defined datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year, and seasons, etc. If we had to store all seven days of a week into one single variable then we might tend to use data ... Read More

Implement Interpolation Search Algorithm in C++

Ravi Ranjan
Updated on 21-Apr-2025 14:40:31

1K+ Views

The interpolation search is an improved version of the binary search. The list is divided using the mid element in the binary search whereas the interpolation search algorithm tries to locate the exact position using the interpolation formula. For this algorithm to work properly, the data collection should be in a sorted form and equally distributed. In this article, we have a sorted array. Our task is to implement the interpolation search algorithm algorithm on this sorted array in C++. The formula used in this algorithm to find the position is given below: Interpolation Position Search Formula pos = ... Read More

Advertisements