Java program to reverse a string using stacks

Aishwarya Naglot
Updated on 05-Jun-2025 11:53:14

2K+ Views

Stack is a linear data structure where we can store elements. It uses the LIFO (last in, first out) principle, which means the item we add last will be the first one to be removed. In this article, we will understand how to reverse a string using stacks. Let's take an example: Input: String input_string = "Java Program"; Output: String reversed_string = "margorP avaJ"; Ways to Reverse a String Using Stacks Below are the different approaches to reverse a string using stacks: Reverse a string using built-in stack methods ... Read More

Java Program to Implement Multiple Inheritance

Manisha Chand
Updated on 05-Jun-2025 11:10:33

15K+ Views

In this article, we will understand how to implement multiple inheritance. Unlike other programming languages, such as C++, Java does not support multiple inheritance through classes. This means that a class cannot inherit from more than one class. But why? Let's understand first what multiple inheritance is and why it is so. Multiple Inheritance Multiple Inheritance is one of the features of object-oriented programming, where a class (child class) can inherit properties of more than one class (parent class) using the extends keyword. But Java does not support this to avoid complexity and ambiguity. It can ... Read More

Java Program to Calculate Simple Interest

Manisha Chand
Updated on 05-Jun-2025 11:05:06

3K+ Views

In this article, we will understand how to write a Java program to calculate simple interest. But, before doing it, let's understand how we calculate simple interest mathematically. The simple interest is a way to determine the amount of interest gained on a principal amount at the specified interest rate for a given time. Unlike compound interest, its principal amount does not change over time. To calculate Simple Interest, we use the following formula− Simple Interest (S.I) = Principal * Time * Rate / 100 where, P is the principal amount T is the time R is the rate ... Read More

Importance of @JsonView annotation using Jackson in Java?

Manisha Chand
Updated on 05-Jun-2025 10:58:46

1K+ Views

Jackson Library: The @JsonView AnnotationIn Java, Jackson is a library that is used to convert JSON to Java objects and vice versa. Jackson Annotations are used during serialization and deserialization. We use these to denote or specify annotations before a particular field or method (that is declared in Java). Using an annotation before a field, we can denote whether a variable is a JsonProperty, should be ignored, or what condition should be applied to it. The JsonView annotation is used to include/exclude ... Read More

Java Program to Check if two of three Boolean variables are true

Manisha Chand
Updated on 05-Jun-2025 10:51:50

476 Views

In this article, we will learn to check if any two out of three boolean values are true or not. Boolean variables are datatypes that contain only true or false values. Below is a demonstration of the same - Input: true, true, falseOutput : Two of the three variables are true Checking if two of three Boolean variables are trueIn this article, we will discuss two approaches to check it, and they are - Using if-else Condition ... Read More

Java program to calculate the compound interest

Manisha Chand
Updated on 05-Jun-2025 10:48:07

16K+ Views

In this article, we will understand how to calculate compound interest in Java. Compound interest is calculated using the following formula. Amount = P(1 + R/100)t Compound Interest = Amount - Principle where, P is the principal amount T is the time R is the rate Compound interest is the interest calculated on the initial principal and also on the accumulated interest of previous periods. In other words, Compound Interest = Interest on Principal + Interest on Interest. We'll learn how to get user input for the principal amount, interest rate, and time period, and then calculate the compound interest based ... Read More

Java Program to Find Even Sum of Fibonacci Series till number N

Manisha Chand
Updated on 05-Jun-2025 10:22:18

3K+ Views

In this article, we will learn how to find the even sum of the Fibonacci series up to a given number N. A Fibonacci series is a series where the next term is the sum of the previous two terms. An even Fibonacci series is a group of all the even numbers in the Fibonacci series. The first two terms of the Fibonacci sequence are 0 and 1. Fn = Fn-1 + Fn-2 Hence, a Fibonacci series can look like this - F8 = 0 1 1 2 3 5 8 13 or, this F8 = 1 1 2 3 5 ... Read More

Decimal type in C#

Samual Sam
Updated on 05-Jun-2025 09:58:40

2K+ Views

The decimal type is a value type and has the plus, minus, multiply and divide operators. Firstly, set two decimal values − decimal d1 = 5.8M; decimal d2 = 3.2M; To add decimals − d1 = d1 + d2; Let us see an example to add two decimal values − Example Live Demo using System; using System.Linq; class Demo { static void Main() { decimal d1 = 5.8M; decimal d2 = 3.2M; d1 = d1 + d2; Console.WriteLine(d1); } } Output 9.0

Java Program to Display All Prime Numbers from 1 to N

Manisha Chand
Updated on 05-Jun-2025 09:55:00

37K+ Views

In this article, we will understand how to display all the prime numbers from 1 to N in Java. All possible positive numbers from 1 to infinity are called natural numbers. A number is a prime number if its only factors are 1 and itself and cannot be divided by any other number. 11 is a prime number. Its factors are 1 and 11 itself. Some examples of prime numbers are 2, 3, 5, 7, 11, 13, and so on. 2 is the only even prime number. All other prime numbers are odd numbers. Below is a demonstration of the ... Read More

How to convert std::string to LPCWSTR in C++?

Aman Kumar
Updated on 04-Jun-2025 18:53:51

3K+ Views

std::string The std::string is a class of C++ Standard Library (STL) that represents a string (sequence of characters). It is used to handle strings with better memory management, i.e., it provides dynamic memory management for strings and supports a rich set of in-built functions for string manipulation. Syntax Following is the syntax of string: string str = "tutorialspoint"; std::LPCWSTR The LPCWSTR stands for Long Pointer to Constant Wide STRing. It is a constant string of 16-bit Unicode characters, which may be null-terminated. It is the same as a string but with wide characters. Syntax Following is the syntax of ... Read More

Advertisements