Found 2617 Articles for Java

Arrange Negative Array Elements Before Positive Elements in Java

Mr. Satyabrata
Updated on 05-Jan-2023 11:33:51

770 Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to arrange all elements of array such that negative elements are present before positive elements. If a number is greater than 0 then it is called as positive number, if less than 0 then it is called as negative number. Note − The array must be an integer array. Let’s explore the article to see how it can be done by using Java programming language. To Show You Some Instances Instance-1 Suppose the ... Read More

JAVA Program to Replace Element of Integer Array with Product of Other Elements

Mr. Satyabrata
Updated on 30-Dec-2022 14:00:34

4K+ Views

Array of Integers refers to an array where all the elements are of Integer type. It is alsocalled an Integer array. As per the problem statement we have to create an Integer array and display the array elements where all the array elements are the product of other elements of the array. In this article, we will see how to replace array elements by the product of other array elements by using Java programming language. To show you some instances − Instance-1 int arr[] = { 2, 3, 1, 4, 6 } At Index-0 value will be = 3 * ... Read More

Java Menu Driven Program to Perform Basic String Operations

Mr. Satyabrata
Updated on 27-Dec-2022 15:05:23

3K+ Views

String refers to a sequence of characters. In Java Strings are objects. To create and manipulate strings Java provides the String class. String class has many inbuilt methods which are used for different purposes. We will perform a few basic string operations by using inbuilt String methods. replace() Method: It replaces a specified character in the given string. concat() Method: It appends another string to the end of one string. length() Method: It returns the length of the given String. Equals() Method: It checks whether two strings are equal or not. In this article, we will see some basic ... Read More

Java Menu Driven Program to Perform Matrix Operation

Mr. Satyabrata
Updated on 27-Dec-2022 14:58:11

2K+ Views

Array in Java is called as a non primitive data type which stores a fixed number of single type values. It is called a one-dimensional array. Whereas matrix refers to a rectangular array or Two-Dimensional array. In this article, we will see how to perform different matrix operations like addition, subtraction, and multiplication by using Java Menu driven program. We will be implementing the application using a switch case. To show you some instances  Instance-1 Suppose we have inserted two different matrices of 2 rows and 3 columns. Then we will perform matrix addition and print the result. Let the ... Read More

Java Program to Enter a Number in Digit and Display in Words

Mr. Satyabrata
Updated on 27-Dec-2022 14:48:25

3K+ Views

Digits are basically represented in number format or these are integer values. But for pronouncing them we are using words. Every digit has a unique word format. For example, the word format of 1 is “One”. Like that for 2 the word format is “two”, for 3 the word format is “three” ... etc. For two-digit number the number format is little different. 21 represents as “twenty-one”, 45 represents as “forty-five” .... etc. So for all type of number there has a unique word format available. To show you some instances  Instance-1 Input number is 15. Word format of 15 ... Read More

Java Menu Driven Program to Perform Queue Operation

Mr. Satyabrata
Updated on 27-Dec-2022 14:44:17

657 Views

Queue is a linear data structure, in Java considered as a collection whch works on the principle of FIFO (First In First Out). In this article we will see how to perform different queue operations like Enqueue, Dequeue, front of the queue, size of the queue, is queue empty or not using Java programming language. We will be implementing the application using a switch case. To show you some instances  Instance-1 Suppose we have entered a queue of size 6 with elements [2, 6, 5, 8, 7, 3]. Then we will perform the Enqueue operation and add element 0. So ... Read More

Java Menu Driven Program to Perform Array Operation

Mr. Satyabrata
Updated on 27-Dec-2022 14:40:45

2K+ Views

Array in Java is called as a non primitive data type which stores a fixed number of single type values. It is called a One-dimensional array. In this article, we will see how to perform different array operations like checking duplicate elements, printing array in reverse order, checking largest element, checking smallest element, finding sum of all array elements by using Java Menu driven program. We will be implementing the application using a switch case. To show you some instances − Instance-1 Suppose we have created an array containing 6 elements and array elements are [2, 4, 6, 2, 6, ... Read More

Java Menu Driven Program to Determine Cost of New Membership

Mr. Satyabrata
Updated on 27-Dec-2022 14:38:24

250 Views

When we go anywhere for any type of membership they have different prices for different plans. For example silver membership, gold membership, diamond membership, platinum membership etc. where the silver membership costs less than others and platinum membership costs more than other plans. In this article we will see how to check the cost of a membership by using the Java programming language. We will be implementing the application using a switch case. To show you some instances  Instance-1 Suppose we have Rs 1840 as base membership price and you want to have a silver membership. The cost of silver ... Read More

Java Menu Driven Program to Check Type of a Number

Mr. Satyabrata
Updated on 27-Dec-2022 14:33:35

361 Views

In Java we have primitive numeric data types for numbers that are short, byte, int, long, float and double. These numeric data types allow us to represent different integer and real numbers based on their range as a specific data type has its lower and upper range. Below are the 6 primitive numeric data types  byte: Range -128 to 127 (Size 1 byte) short: Range -32, 768 to 32, 767 (Size 2 bytes) int: Range -2, 147, 483, 648 to 2, 147, 483, 647 (Size 4 bytes) long: Range -9, 223, 372, 036, 854, 775, 808 to 9, 223, 372, ... Read More

JAVA Menu Driven Program to Check Character is String, Number or Special Character

Mr. Satyabrata
Updated on 31-May-2024 14:47:53

10K+ Views

In this article, we will see a menu driven program to check if the entered character is number, string or special character by Java programming language. We will be implementing the application using a switch case. To show you some instances  Instance-1 Suppose the entered character is ‘a’ then the output should be “Entered character is a String”. Instance-2 Suppose the entered character is ‘1’ then the output should be “Entered character is a number”. Instance-3 Suppose the entered character is ‘$’ then the output should be “Entered character is a Special character”. Syntax To check whether ... Read More

Advertisements