Java Articles

Page 210 of 450

Java program to convert the contents of a Map to list

Ankith Reddy
Ankith Reddy
Updated on 31-May-2024 32K+ Views

The Map class's object contains key and value pairs. You can convert it into two list objects one which contains key values and the one which contains map values separately. To convert a map to list − Create a Map object. Using the put() method insert elements to it as key, value pairs Create an ArrayList of integer type to hold the keys of the map. In its constructor call the method keySet() of the Map class. Create an ArrayList of String type to hold the values of the map. In ...

Read More

Java program to convert the contents of a Map to list

Ankith Reddy
Ankith Reddy
Updated on 31-May-2024 32K+ Views

The Map class's object contains key and value pairs. You can convert it into two list objects one which contains key values and the one which contains map values separately. To convert a map to list − Create a Map object. Using the put() method insert elements to it as key, value pairs Create an ArrayList of integer type to hold the keys of the map. In its constructor call the method keySet() of the Map class. Create an ArrayList of String type to hold the values of the map. In ...

Read More

Java program to calculate Body Mass Index (BMI)

Samual Sam
Samual Sam
Updated on 31-May-2024 31K+ Views

The Body Mass Index is the body mass in kilogram divided by the square of body height in meters. This is expressed as kg/m^2.A Java program that calculates the Body Mass Index (BMI) is given as follows.Exampleimport java.util.Scanner; public class Example {    public static void main(String args[]) {       Scanner sc = new Scanner(System.in);       System.out.print("Input weight in kilogram: ");       double weight = sc.nextDouble();       System.out.print("Input height in meters: ");       double height = sc.nextDouble();       double BMI = weight / (height * height);     ...

Read More

How To Install Apache Maven on Ubuntu

Sharon Christine
Sharon Christine
Updated on 01-Mar-2024 345 Views

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information. This article explains about how to install apache maven on Ubuntu.To install apache maven, it should require pre-installed java on Ubuntu. To verify java version, use the following command –$ java -versionThe sample output should be like this –openjdk version "1.8.0_111" OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-2ubuntu0.16.04.2-b14) OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)If you wants to install java on Ubuntu, read this articleTo install ...

Read More

Fibonomial coefficient and Fibonomial triangle

Vaishnavi Tripathi
Vaishnavi Tripathi
Updated on 09-Feb-2024 225 Views

In this article, we will discuss about a special type of number called fibonomial coefficient and how does a fibonomial triangle looks like. We will also discuss the C++ code approach to print a fibonomial triangle with a given height. Let us first discuss that what is a fibonomial coefficient. Fibonomial Coefficient We can call a fibonomial coefficient a generalisation of well known terms namely , Fibonacci numbers and binomial coefficients. The Fibonacci numbers are a series of numbers in which, each number is the sum of the two preceding numbers (for example − 0, 1, 1, 2, 3, 5, ...

Read More

Code Solution to sword puzzle

Vaishnavi Tripathi
Vaishnavi Tripathi
Updated on 09-Feb-2024 557 Views

We will discuss two approaches to solve the sword puzzle. In the first approach, we will use circular linked list, while the second approach is based on general intuition. In this article, we will discuss what is a sword puzzle problem and how we can solve a sword puzzle problem. Problem Statement We have an arrangement of n people in a circle in which, first person is carrying a sword. The first person kills the second person and hands over the sword to the next alive person in the circle. Now the next person carrying the sword kills the next ...

Read More

Count subsequences 01 in string generated by concatenation of given numeric string K times

Esha Thakur
Esha Thakur
Updated on 09-Feb-2024 374 Views

The analysis and manipulation of strings are fundamental operations in many applications of computer programming. Counting subsequences with the pattern "01" in a string formed by repetitively concatenating a given numeric string poses an interesting challenge. The primary question is determining the total count of such subsequences in the resulting string. This article discusses a useful C++ approach to solve this issue successfully and offers a solid answer to deal with this particular work. Concept of Subsequence A subsequence is a sequence of characters that is derived from some other sequence by eliminating zero or more characters without altering the ...

Read More

Program to find the sum of series 1*2*3 + 2*3*4+ 3*4*5 + . . . + n*(n+1)*(n+2)

Disha Gupta
Disha Gupta
Updated on 05-Feb-2024 964 Views

The sum of the series is the value of all terms in the given series added together in a particular pattern. Here given pattern is in the form of the: ∑ (n*(n+1)*(n+2)) as (n*(n+1)*(n+2)) is the last term in the given pattern. The following article discusses 3 approaches in detail to find the given sum of the series with different time and space complexities. Problem Statement Now, let us see how to calculate the sum of series 1*2*3 + 2*3*4 + 3*4*5 + . . . + n*(n+1)*(n+2). Sample Examples Let’s try to understand this problem with the help ...

Read More

Count of substrings with the frequency of at most one character as Odd

Disha Gupta
Disha Gupta
Updated on 05-Feb-2024 486 Views

Substrings are the subsets or sequences of contiguous characters of a string. Now, in this problem, we need to find the number of substrings with the frequency of at most one character as odd. Let us see how we should proceed to solve this problem. Let’s try to understand this problem with the help of some examples. Input s = “ksjssjkk” Output 21 Explanation − As the frequency of the characters in the given string is given below− k → 3 s → 3 j → 2 Now, substrings with ...

Read More

Find the next number by adding natural numbers in order on alternating indices from last

Disha Gupta
Disha Gupta
Updated on 05-Feb-2024 230 Views

A numerical string is used to store a value of a number if we want to store a huge valued integer. As we know, we can not store a number greater than 32 bits in the computer with its datatype as int. So to avoid the overflowing condition, in this problem, we will take a numerical string as our input rather than an int variable so that we can work this problem on a larger scale of numbers. Problem Statement Now, in this problem, we need to find the following number by adding natural numbers in order on alternating indices ...

Read More
Showing 2091–2100 of 4,498 articles
« Prev 1 208 209 210 211 212 450 Next »
Advertisements