Código:
import java.util.Random; public class ProgramaTarea1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int x[] = new int [1000]; int mayor; long startTime = System.currentTimeMillis(); ProgramaTarea1 Mayor = new ProgramaTarea1(); //Mayor.ElementoMayor(x); mayor=Mayor.ElementoMayor(x); System.out.println("El Numero mas grande es: "+mayor); long endTime = System.currentTimeMillis(); System.out.println("El tiempo total de ejecución del método Mayor Elemento() es :"+ (endTime-startTime) + " milisegundos"); } public int ElementoMayor(int x[]) { // TODO Auto-generated method stub int n=0,mayor=0; System.out.println("Llamando el Metodo del Mayor"); Random rnd = new Random(); for(int i=0;i<=1000;i++) { n = (int)(rnd.nextDouble() * 100000.1); x[i]=n; //System.out.println("Value of counter is "+i); } for (int i = 0; i < 1000; i++) { if(x[i]>mayor) { mayor=x[i]; } } return mayor; //System.out.println("El Numero mas grande es: "+mayor); } }