import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
int [] arr = {2,3,4,5,5};
System.out.println("arr length="+arr.length);
for(int i=arr.length-1; i>0;--i)
{
System.out.println(arr[i]);
}
// maximum, minimum in array
int[] arr2 = {2,4,6,7,67,89};
int max =0;
for (int elmnt :arr2)
{ if (elmnt>max)
max = elmnt;
}
System.out.println(max);
/// array sorted or not mean ascending order
System.out.println("array check sorted or not ");
int [] arr3 = {3,4,5,44,55,66};
boolean tryy = true;
for (int i=0; i<arr3.length-1;i++)
{
if (arr3[i]>arr3[i+1])
{ // System.out.println("array is not sorted");
//System.exit(0);
tryy = false;
break;
}
} if (tryy ==false )
System.out.println("array is not sorted");
else // if (tryy ==true ) we can also write this
System.out.println("array is sorted");
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: