arrays program

arrays program

View Answers

July 18, 2009 at 5:10 PM

Hi Friend,

Try the following code:

public class MaxMin{
public static void main(String[] args) {

int []num={100,20,152,24,456,651,258,35};
int max = num[0];
int min = num[0];

for (int i=1; i<num.length; i++) {
if (num[i] > max) {
max = num[i];
}
}
System.out.println("Largest Number: "+max);
for (int i=1; i<num.length; i++) {
if (num[i]< min) {
min = num[i];
}
}
System.out.println("Smallest Number: "+min);
}
}

Thanks









Related Tutorials/Questions & Answers:
arrays program - Java Interview Questions
arrays program  how to write our own array program to find out n'th highest and n'th least i want source code plz replyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy  Hi Friend, Try the following
Why is my program running an infinite loop? Parallel Arrays Program
Why is my program running an infinite loop? Parallel Arrays Program  Calculate and print the average (this works) Search for Joel in the list, print his data----for some reason this is outputting the wrong data and is outputting
Advertisements
arrays
arrays  using arrays in methods   Java use arrays in methods import java.util.*; class ArrayExample{ public static int getMaxValue(int[] arr){ int maxValue = arr[0]; for(int i=1;i < arr.length;i
arrays
Store a table with students and information (name, ID, password, crypted password, etc) in a multi-dimensional array "stud"  Arrays and Strings: Store a table with students and information (name, ID, password, crypted password
Arrays
Arrays   Hi I need help with the following exercises. Exercise 1: Write a Java application in which the user is prompted for the total number of integer values to be stored in an array. Initialize the array with random values
Arrays
called Rebel.java; 2.Create two arrays. One of them must store integer numbers... the numbers in the second array by 3; 7.Print out the contents of both arrays. 8.Swap
Arrays
Arrays  Write a program in java(BlueJ) to store the numbers in single dimensional array(S.D.A)into another S.D.A in reverse order of the location
arrays
arrays  Write a program to print details of all the months with number of days in a year (Leap or Non Leap year) using array of objects Integer and String
arrays
arrays  i want an array program in which user must enter elements and every element can not have a duplicate if duplicate then write duplicate and press another number. (duplicacy is check during user enter elements not after
arrays
arrays  i want an array program in which user must enter elements and every element can not have a duplicate if duplicate then write duplicate and press another number. (duplicacy is check during user enter elements not after
Arrays
Arrays  Create a program to mark and grade a set of multiple choice... the program must prompt the user for the student name and thereafter for the student's... number of correct answers as shown above To end the program display a dialog box
arrays
arrays  write a program that reads in a text typed in by the user and produces a list of disinct words in alphabetical order and how many times each word appears in the passage.   The given code accepts the string text
arrays
arrays  write a program that reads in a text typed in by the user and produces a list of disinct words in alphabetical order and how many times each word appears in the passage.   The given code accepts the string text
arrays
arrays  write a program that reads in a text typed in by the user and produces a list of disinct words in alphabetical order and how many times each word appears in the passage.   The given code accepts the string text
java arrays
java arrays  i need a java program to store student details like id,name,addr,marks,average,total..using arrays..input data using scanner class and by using class, object and constructor
Arrays in java
Arrays in java  what is param array in java
ModuleNotFoundError: No module named 'Arrays'
ModuleNotFoundError: No module named 'Arrays'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Arrays' How to remove the ModuleNotFoundError: No module named 'Arrays'
Java with Arrays
arrays; both of size 50 (declares 50 as a constant) One is an array of strings... and store it in the arrays. The input for the problem should be provided in a text field, the program will read the input from the file. .. can someone please help
java; arrays - Java Beginners
java arrays example  How can you create a program, by using arrays and the output would be X. by using char or string.Thank you
What is javascript Arrays?
What is javascript Arrays?   Hi, I am learner of JavaScript. My question is that What is JavaScript Arrays ? How to Define the JavaScript arrays in you program. Please give an example show that i will try my self. Thanks
java arrays
java arrays  can i know how can we intilize the three dimentional arrays in java? and how can we assign thae values to that array
arrays
Arrays
Arrays
arrays
arrays
Compare two Byte Arrays?
Compare two Byte Arrays?  Compare two Byte Arrays
Comparing arrays not working correctly?
Comparing arrays not working correctly?  Comparing arrays not working correctly
create arrays in JavaScript
create arrays in JavaScript  How to create arrays in JavaScript
How to create arrays in JavaScript?
How to create arrays in JavaScript?  How to create arrays in JavaScript
ModuleNotFoundError: No module named 'match-arrays'
ModuleNotFoundError: No module named 'match-arrays'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'match-arrays' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'stats-arrays'
ModuleNotFoundError: No module named 'stats-arrays'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'stats-arrays' How to remove the ModuleNotFoundError: No module named '
java arrays
java arrays  how do you write the code for multipliying 2 double arrays to be in a 3rd double array? here is my code: package employeepay; /** * * @author Owner */ public class Main {ADS_TO_REPLACE_1 /** * @param args
reverse arrays in java
reverse arrays in java  how do i write a program in array of size n*m where both n and m are greater than 20 such that the 1st element of an array becomes the last and vice verse
intersection of two java arrays
to compare two arrays and get the intersection and put this into a third array of the correct size. I know how to copy the two arrays into the third array but am... use set collections with the program either. Any help on the direction to go
java arrays
the program
Comparing Arrays
are same or not. The given program illustrates you how to compare arrays according.... And then  the program checks whether the given taken both arrays are same... for manipulating arrays. Here is the code of the program:ADS_TO_REPLACE_2
arrays in java - Java Beginners
arrays in java  Hi All, I have two arrays. in this two array some name are same. I want to merge those arrays into single. But while merging I want to delete duplicate entries. How merge those arrays. Thanks, mln15584
Arrays - Java Interview Questions
a program that take arrays A & B as input and find missing element in B array? 3)Write a program that taking array values from keyboard? And should return...Arrays  1)write a program that take integer array as input and find
Are arrays primitive data types?
Are arrays primitive data types?   Hi, Are arrays primitive data types? thanks   Hi, In Java, Arrays are objects. Identifier are some simple variable names which is defined as the value container. The type of value
Introduction to java arrays
Introduction to java arrays   ... of Arrays in Java Programming language. You will learn how the Array class... manageable format.  Program data is stored in the variables and takes the 
ModuleNotFoundError: No module named 'sig-process-arrays'
ModuleNotFoundError: No module named 'sig-process-arrays'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'sig-process-arrays' How to remove the ModuleNotFoundError: No module
arrays help - Java Beginners
arrays help  Write a program that sorts values. ? The program..., and o returns the array   ? The program includes easySort() that o sorts...() ? The program reads the user inputs by using readIntegers(), sorts the input values
combine two arrays in php
combine two arrays in php  combine two arrays in php   $newArray = array_combine($diff, $pages_name['data']); foreach ($newArray as $data) { var_dump($data); exit('zzzzz'); echo $data . '<br>
Arrays in java 7
This tutorial describes the concept of Arrays in java 7
java 2d arrays
java 2d arrays  Create a program that will: a) Create the array and populate it with the given values. 9, 8 2, 17 49, 4 13, 119 2, 19 11, 47.... and if i do it manualy it is wrong. public class Arrays { public static void main
swap two integer arrays
swap two integer arrays  int [] array1 = {1,2,3,4,5} int [] array2 = {6,7,8,9,10} how can we swap the values of bith integer arrays results like this array1 = {6,7,8,9,10} array2 = {1,2,3,4,5
swap two integer arrays
swap two integer arrays  int [] array1 = {1,2,3,4,5} int [] array2 = {6,7,8,9,10} how can we swap the values of bith integer arrays results like this array1 = {6,7,8,9,10} array2 = {1,2,3,4,5
reverse arrays in java
reverse arrays in java  how do i make a code that can be used to reverse the elements of an array in two dimension such that the last element of an array becomes the first element of the array and the first element of an array
swap two integer arrays
swap two integer arrays  int [] array1 = {1,2,3,4,5} int [] array2 = {6,7,8,9,10} how can we swap the values of bith integer arrays results like this array1 = {6,7,8,9,10} array2 = {1,2,3,4,5

Ads