Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

array

By: a guest on Nov 19th, 2012  |  syntax: Java  |  size: 0.79 KB  |  hits: 58  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class myArray{
  2.    
  3.     public static void main (String[]args){
  4.        
  5.            
  6.            
  7.         boolean error = true;    
  8.         int[] myArray=new int [15];
  9.            
  10.         for(int i =0;i<myArray.length-1;i++){
  11.                 double r = Math.random()*100;
  12.                 myArray[i] = (int)r;
  13.                 System.out.print(myArray[i]+", ");
  14.                
  15.          }
  16.            
  17.         System.out.println();
  18.            
  19.         for(int i =0;i<myArray.length-1;i++){
  20.                 if(myArray[i]>myArray[myArray.length-1]){//Why does this not work?
  21.                 System.out.print(myArray[i]+", ");
  22.                 error = false;
  23.                 }
  24.                
  25.          }
  26.          
  27.         if(error == true){System.out.println("the last number is the largest");}
  28.    
  29.     }
  30.    
  31.    
  32. }