Karthikeya Boyini has Published 2193 Articles

strdup() and strdndup() in C/C++

karthikeya Boyini

karthikeya Boyini

Updated on 03-Dec-2024 09:44:41

7K+ Views

strdup() The function strdup() is used to duplicate a string. It returns a pointer to a null-terminated byte string. Syntax Here is the syntax of strdup() in C language, char *strdup(const char *string); Example Here is an example of strdup() in C language. #include #include int main() {  char ... Read More

How to use enums in C++?

karthikeya Boyini

karthikeya Boyini

Updated on 02-Dec-2024 00:23:27

10K+ Views

Enumeration is a user defined datatype in C/C++ language. It is used to assign names to the integral constants which makes a program easy to read and maintain. The keyword “enum” is used to declare an enumeration. The following is the syntax of enums. Syntax enum enum_name{const1, const2, ....... }; ... Read More

Java program to convert LocalDateTime to java.util.Date

karthikeya Boyini

karthikeya Boyini

Updated on 29-Nov-2024 19:11:15

2K+ Views

In this article, we will learn how to convert a LocalDateTime object to a java.util.Date object in Java. The conversion is essential when working with modern and legacy date/time APIs, ensuring compatibility between them. LocalDateTime Class The java.time.LocalDateTime class represents a specific date and time without including any ... Read More

Java program to replace all occurrences of a given character in a string

karthikeya Boyini

karthikeya Boyini

Updated on 19-Nov-2024 18:23:54

3K+ Views

In this article, we will learn to replace all occurrences of a given character in a string in Java. Replace() method The replace() method in Java is used to replace all occurrences of a given character in a string with another character. In this example, we will replace all occurrences ... Read More

Java program to add and remove elements from a set which maintains the insertion order

karthikeya Boyini

karthikeya Boyini

Updated on 19-Nov-2024 18:23:22

585 Views

In this article, we will learn how to use a LinkedHashSet in Java to add and remove elements while maintaining the insertion order. You will see how elements are stored, removed, and updated in a LinkedHashSet without altering the sequence in which they were added. Problem Statement Write a Java ... Read More

Java program to get the current value of the system timer in nanoseconds

karthikeya Boyini

karthikeya Boyini

Updated on 18-Nov-2024 22:30:20

343 Views

In this article, we use the System.nanoTime() method in Java to get the current value of the system timer in nanoseconds. It returns the current value of the most precise available system timer, in nanoseconds. Problem StatementGiven that you need to get the current value of the system timer ... Read More

Java program to check if a string is empty or not

karthikeya Boyini

karthikeya Boyini

Updated on 15-Nov-2024 18:43:36

409 Views

In this article, we will learn how to check if a String is empty in Java. The isEmpty() method is used to check whether a given string does not contain characters. Problem StatementGiven a string, write a Java program to determine if the string is empty.Input String str ... Read More

Java program to create a file and sets it to read-only

karthikeya Boyini

karthikeya Boyini

Updated on 15-Nov-2024 18:42:46

194 Views

In this article, we will learn to use Java to make a file read-only and check if it can still be written. A file can be set to read-only by using the method java.io.File.setReadOnly(). This method requires no parameters and returns true if the file is set to read-only and ... Read More

Java program to check whether the entered value is ASCII 7 bit alphabetic uppercase

karthikeya Boyini

karthikeya Boyini

Updated on 15-Nov-2024 18:41:31

155 Views

In this article, we will explore how to verify whether or not a given character is an uppercase letter and, more specifically, falls within the range of A to Z. This is useful when a user’s input consists of some uppercase letter or when a program needs to restrict itself to ... Read More

Java program to convert a string into a numeric primitive type using Integer.valueOf()

karthikeya Boyini

karthikeya Boyini

Updated on 13-Nov-2024 19:19:45

851 Views

This article will teach us to convert a string into a numeric primitive type using Integer.valueOf() in Java. By the end, you’ll see how this method takes a string of numbers and transforms it into an integer type, making it usable for arithmetic operations or any other number-based logic. Problem ... Read More

Advertisements