Write a program to find maximum and minimum number in array?
Answer / Preeti Arora
Here is a simple Java program to find the maximum and minimum numbers in an array:n```javanpublic class FindMaxMin {n public static void main(String[] args) {n int[] arr = {1, 5, 3, 7, 2};n int max = arr[0];n int min = arr[0];n for (int i = 1; i < arr.length; i++) {n if (arr[i] > max) {n max = arr[i];n }n if (arr[i] < min) {n min = arr[i];n }n }n System.out.println("Maximum number: " + max);n System.out.println("Minimum number: " + min);n }n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
how many types of Inheritance?
Explain an intermediate language?
can we overload main method?
What is Difference between Serializable and Externalizable in Java serialization?
What are the topics in advance java?
What are the different types of inheritance in java?
What is the default modifier in Interface?
Which is better stringbuilder or stringbuffer?
Can an unreferenced object be referenced again?
What is final keyword?
What is a nullable field?
What do you mean by byte code?