Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


bhaskarreddy
arrays program
1 Answer(s)      5 years and 3 months ago
Posted in : Java Interview Questions



Advertisement
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
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  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  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
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
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 { /** * @param args the command line
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
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
Compare two Byte Arrays?
Compare two Byte Arrays?  Compare two Byte Arrays
How to create arrays in JavaScript?
How to create arrays in JavaScript?  How to create arrays in JavaScript
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
 

 

 

DMCA.com