- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find numbers in an array that are greater than, less than, or equal to a value in java?
You can find numbers in an array that are greater than, less than, or equal to a value as:
Example
public class GreaterOrLess { public static void main(String args[]) { int value = 65; int[] myArray = {41, 52, 63, 74, 85, 96 }; System.out.println("Elements of the array that are equal to the given value are::"); for(int i = 0; i<myArray.length; i++) { if(value==myArray[i]) { System.out.println("Index ::"+i+" Element::"+myArray[i]); } } System.out.println("Elements of the array that are greater than the given value are::"); for(int i = 0; i<myArray.length; i++) { if(value<=myArray[i]) { System.out.println("Index ::"+i+" Element::"+myArray[i]); } } System.out.println("Elements of the array that are less than the given value are::"); for(int i = 0; i<myArray.length; i++) { if(value>myArray[i]) { System.out.println("Index ::"+i+" Element::"+myArray[i]); } } } }
Output
Elements of the array that are equal to the given value are:: Elements of the array that are greater than the given value are:: Index ::3 Element::74 Index ::4 Element::85 Index ::5 Element::96 Elements of the array that are less than the given value are:: Index ::0 Element::41 Index ::1 Element::52 Index ::2 Element::63
- Related Articles
- Mask an array where less than or equal to a given value in Numpy
- Mask array elements greater than or equal to a given value in Numpy
- Complete the following statements:The probability of an event is greater than or equal to …………. and less than or equal to ………..
- How to check whether a column value is less than or greater than a certain value in R?
- Find all factorial numbers less than or equal to n in C++
- Check if any value in an R vector is greater than or less than a certain value.
- An angle is greater than $45^{\circ}$. Is its complementary angle greater than $45^{\circ}$ or equal to $45^{\circ}$ or less than $45^{\circ}$?
- How to find the frequency of values greater than or equal to a certain value in R?
- How to represent X-axis label of a bar plot with greater than equal to or less than equal to sign using ggplot2 in R?
- An angle is greater than \( 45^{\circ} \). Is its complementary angle greater than \( 45^{\circ} \) or equal \( 45^{\circ} \) or less than \( 45^{\circ} ? \)
- Count elements less than or equal to a given value in a sorted rotated array in C++
- Print all prime numbers less than or equal to N in C++
- Find maximum sum array of length less than or equal to m in C++
- How To Check If Time Is Greater Than Or Less Than A Specific Time In Excel?
- How to create a subset of matrix in R using greater than or less than a certain value of a column?

Advertisements