Find the min and max in an Array

import java.util.Arrays;

 * Java program to find maximum and minimum numbers in given array
public class MaximumMinimumArray {

	public static void main(String[] args) {
		int numbers[] = {1,2,3,4,5,6,7};

	private static void findMaxAndMin(int[] numbers) {
		int smallest = numbers[0];
		int largest = numbers[0];

		for (int i : numbers) {
			if(i > largest){
				largest = i;
			}else if(i <smallest){
				smallest = i;

		System.out.println("Given integer array :"+Arrays.toString(numbers));
		System.out.println("larget number : "+ largest);
		System.out.println("smallest number : "+ smallest);


About sivateja

I am a professional graduate..I am passionate about Latest Technology.
This entry was posted in Programing questions, Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s