Found 7442 Articles for Java

Capitalize last letter and Lowercase first letter of a word in Java

Mr. Satyabrata
Updated on 05-Jan-2023 11:56:58

7K+ Views

String is a sequence of character values. In Java, Strings are considered as objects. We have a String class provided by Java for creating and manipulating strings. We have to convert the first letter of the word to lowercase and last letter of the word to uppercase. In this article we will see how the first and last letter can be converted into lower and upper case respectively. Let’s explore. To Show You Some Instances Instance-1 Suppose the input string is “Hello” After converting the first letter to lower and last letter to capital, the new string will be “hellO” ... Read More

Find if sum of odd or even array elements are smaller in Java

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

1K+ 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 find the sum of elements which is even and sum of elements which is odd in an array and compare their sum and check which one is smaller. A number is said to be even if it is divisible by 2 else it is called an odd 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. ... Read More

Check Average of Odd Elements or Even Elements are Greater in Java

Mr. Satyabrata
Updated on 05-Jan-2023 11:45:21

641 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 find the sum of all even and odd numbers in a given array and compare them to see which one is greater. 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 original array is {14, 49, 55, 67, 72, 82} After finding average of sum of even and ... Read More

Check if Array is Free From 0 and Negative Number in Java

Mr. Satyabrata
Updated on 05-Jan-2023 11:39:58

2K+ 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 check and confirm the array is free from 0 and negative numbers. Let us say that an array contains 0 or a negative element then the result should pop up that "Array contains 0 or a negative number." Otherwise, the result should be "Array doesn’t contain 0 or a negative number." Note − The array must be an integer array. Let’s explore the article to see how it can be done by using ... Read More

Arrange Negative Array Elements Before Positive Elements in Java

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

1K+ 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

4K+ 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

4K+ 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

Shriansh Kumar
Updated on 16-Aug-2024 08:17:30

1K+ Views

A queue is a linear data structure where elements are stored in the FIFO manner. Here, FIFO stands for First In First Out which means the first element inserted would be the first element to be accessed. In this article we will see how to perform different queue operations like Enqueue and Dequeue using Java programming language. Queue in Java In Java, the Queue interface, a sub interface of Java Collection Interface, provides the features of queue data structure. Since it is an interface, the Queue interface needs a concrete class for the implementation and the most common classes are ... Read More

Advertisements