Java Program to find the frequency of odd & even numbers in the given matrix17 Mar 2025 | 2 min read In this program, we need to find the frequencies of odd and even numbers present in the matrix. ![]() In the above example, all odd numbers are represented by the blue square and even numbers are represented by red circles. To find the frequencies of odd and even numbers, loop through the array and check if the element of the array is divisible by 2. If it is divisible by 2(even) then, increment the count of countEven by 1. Else, increment the countOdd by 1. Algorithm
ProgramOutput: Frequency of odd numbers: 5 Frequency of even numbers: 4 Next TopicJava Programs |
A binary tree is given whose edges are undirected and whose nodes are connected. Also, the tree is not cyclic. The binary tree is made up of t nodes that are numbered from 0 to t - 1 and have exactly t - 1 edge. Every...
21 min read
In this program, we need to find the duplicate characters in the string. Great responsibility To find the duplicate character from the string, we count the occurrence of each character in the string. If count is greater than 1, it implies that a character has a duplicate...
3 min read
We can reverse each word of a string by the help of reverse(), split() and substring() methods. By using reverse() method of StringBuilder class, we can reverse given string. By the help of split("\\s") method, we can get all words in an array. To get...
1 min read
It is very interesting problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, Accenture, etc. By solving the problem, one wants to check the logical ability, critical thinking, and problem-solving skill of the interviewee. So, in this section, we are going to...
2 min read
It is a very interesting problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, Accenture, etc. By solving the problem, one wants to check the logical ability, critical thinking, and problem-solving skill of the interviewee. So, in this section, we are going...
19 min read
Java String to float We can convert String to float in java using Float.parseFloat() method. Scenario It is generally used if we have to perform mathematical operations on the string that contains float number. Whenever we get data from textfield or textarea, entered data is received as a string....
1 min read
Write a code to check whether one string is a rotation of another? File: RotationString .java public class RotationString { public static boolean checkRotation(String st1, String st2) { if (st1.length() != st2.length()) { return false; } String st3 = st1 + st1; if (st3.contains(st2)) return true; else return false; } public static void main(String[] args) { String str1...
1 min read
In this section, we have created a number of Java program to check if a given number is perfect square or not. The perfect square or square number is a positive integer that is square of an integer. In other words, when we multiply two same numbers...
6 min read
Java Program to Count the Total Number of Punctuation Characters Exists in a String In the ious Java string programs, we have counted the number of words, white spaces, vowels, consonants, and characters. Sometimes it also becomes necessary to count the total number of punctuations in...
2 min read
In this program, we will create a doubly linked list and remove the duplicate, if present, by traversing through the list. Original List: List after removing duplicates: In above list, node2 is repeated thrice, and node 3 is repeated twice. Current will point to head, and index will...
7 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India