java- object-oriented - Static Application

/*

Static Application

Each application has a common function,

These functions may be decimated, independent package,

To reuse

*/

class Demo

{  

  public static void main(String[] args)

  {

    int[] arr = (2,4,1,8);

    int max = getMax(arr);

    System.out.pirntln("max"+max);

  }

  public static int getMax(int[] arr)

  {

    int max = 0;

    for(int x=1;x<arr.length;x++)

    {

      if(arr[x]>arr[max])

        max=x;

    }

    return arr[max];

   }

}

 

Guess you like

Origin www.cnblogs.com/up-day/p/11731386.html