Programming Articles

Page 1709 of 2547

Difference between Procedural and Functional Programming Languages

Shirjeel Yunus
Shirjeel Yunus
Updated on 03-Jul-2024 2K+ Views

Procedural programming is a type of programming in which different functions or routines are created which consists of a sequence of instructions. Functional programming is used to organize the functions. Each function has to be set in such a way that they can perform the required task. We will discuss the difference between procedural programming languages and functional programming languages. Procedural Programming Languages Procedural programming languages have functions which you have to define. These functions need to have a set of instructions which should be executed when the function is called. You have to think about each instruction that you ...

Read More

Difference between Interpreted and Compiled Languages

Shirjeel Yunus
Shirjeel Yunus
Updated on 03-Jul-2024 2K+ Views

Programming languages can be interpreted or compiled. The compiled languages are not interpreted and there is no need to compile the interpreted languages. In this article, we will discuss the difference between compiled and interpreted languages. Compiled Programming Languages Compiled programming languages are the languages in which the code has to be compiled to convert it into machine language. This helps the processor execute the code and provide the result. C, C++, C#, Java, etc. are some of the languages which have to be compiled and then executed. What is Compile? Compile is a process which is used to convert ...

Read More

Java Program for Binary Insertion Sort

AmitDiwan
AmitDiwan
Updated on 02-Jul-2024 4K+ Views

Binary insertion sort uses the binary search to find the right position to insert an element at a specific index at every iteration. First, the location where the element needs to be inserted is found. Then, the elements are shifted to the next right location. Now, the specific element is placed in the position. Problem Statement Given an integer of array implement binary insertion sort using Java to sort it. The algorithm should use binary search to determine the correct position for each element and to maintain the sorted order it will shift elements accordingly. Steps for Binary Insertion ...

Read More

Java program to double the size of an array

karthikeya Boyini
karthikeya Boyini
Updated on 02-Jul-2024 4K+ Views

In this article, we will learn how to double the size of an array in Java. This involves creating a new array with twice the length of the original array and copying the elements from the original array to the new, larger array. Problem Statement Create an initial array with predefined integer values and determine its length. Then, create a new array with double the length of the original array, copy the elements from the original array to the new one, and print the lengths of both the original and the new arrays to verify the resizing operation. Steps to ...

Read More

Java program to convert LocalDate to java.util.Date in UTC

Samual Sam
Samual Sam
Updated on 02-Jul-2024 6K+ Views

In this article, we will learn how to convert a local date to a java.util.Date in UTC using Java's date and time API. Problem Statement Convert the current date, to a java.util.Date object in Coordinated Universal Time (UTC). The goal is to achieve this conversion while ensuring that the resulting java.util.Date object represents the start of the day in UTC for the given LocalDate. Steps to Convert LocalDate to java.util.Date in UTC The following are the steps to convert LocalDate to java.util.Date in UTC Step 1: Import the required classes i.e., java.time and java.util ...

Read More

Java Program for Closest Prime Number

Mr. Satyabrata
Mr. Satyabrata
Updated on 02-Jul-2024 3K+ Views

A prime number is a positive integer greater than 1 that is only divisible by 1 and itself. Prime numbers are an essential concept in mathematics and computer science. They are integers that are only divisible by 1 and themselves. Finding prime numbers is an important task in many algorithms, and there are several methods to determine if a number is prime. One such problem is finding the closest prime number to a given number. Problem Statement For a given number find the closest prime number by using Java programming language. Consider the following example - Input ...

Read More

Java Program to Toss a Coin

Samual Sam
Samual Sam
Updated on 28-Jun-2024 5K+ Views

Tossing a coin is flipping a coin into the air and letting it fall back down. When you toss a coin, it's like a game where you can choose heads or tails, and the side that lands facing up is the result. This method is used when we want to make decisions or settle things randomly. Problem Statement Create a Java program to simulate the flipping of a coin 10 times, recording the number of times the result is "heads" and "tails". Output Chances = 10 Heads: 3 Tails: 7 Algorithms Step-1: Create an instance of the "Toss" ...

Read More

Java Program to Get the Union & Intersection of Two TreeSet

Shiva Keerthi
Shiva Keerthi
Updated on 26-Jun-2024 565 Views

TreeSet is a class that implements Set interface in Java. In TreeSet the elements are stored in sorted order as it is implemented internally using a sorted balanced tree called as binary search tree. The elements in the TreeSet are stored in ascending order by default. Union of sets contains all the elements from both sets. Intersection of sets contain all the elements which are commonly present in both sets. In this section, we will be discussing about how to get the union and intersection of two TreeSet using Java. What are the Union and Intersection of Sets? ...

Read More

Java Program to Get TreeMap Key, Value, or Entry Greater or Less than the Specified Value

Shiva Keerthi
Shiva Keerthi
Updated on 25-Jun-2024 1K+ Views

A TreeMap is a class provided by Java that implements Map Interface. It is a collection of key-value pairs and the key-value pairs in TreeMap are stored in sorted order based on key values. An Entry is defined as a key-value pair in a TreeMap. In this article, we will look in detail how to get TreeMap key-value pair or entry greater or less than the specified value. Methods Used Now, we will be looking into some of the inbuilt methods and their functionality of TreeMap which are used in this particular article. higherKey() − This method is ...

Read More

Java Program to convert boolean to integer

karthikeya Boyini
karthikeya Boyini
Updated on 25-Jun-2024 13K+ Views

To convert boolean to integer, let us first declare a variable of boolean primitive. boolean bool = true; Now, to convert it to integer, let us now take an integer variable and return a value “1” for “true” and “0” for “false”. int val = (bool) ? 1 : 0; Let us now see the complete example to convert boolean to integer in Java. Example public class Demo {    public static void main(String[] args) {       // boolean       boolean bool = true;       System.out.println("Boolean Value: "+bool);       int val = (bool) ? 1 : 0;       // Integer       System.out.println("Integer value: "+val);    } }OutputBoolean Value: true Integer value: 1

Read More
Showing 17081–17090 of 25,466 articles
Advertisements