{}
BLACK NOVEMBER
Get 83% off PRO
Are you struggling to build your coding confidence or land your first job?
Fast-track to your first pay-check.
Start FREE trial →
Start FREE trial →
BLACK NOVEMBER
Get 83% off PRO
Are you struggling to build your coding confidence or land your first job?
Fast-track to your first pay-check.
Start FREE trial →
Start FREE trial →
run-icon
Main.java
import java.util.Scanner; class LinearSearch { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("enter the size of array="); int n=sc.nextInt(); int [] arr =new int[n]; System.out.println("\n enter the elements of array="); for(int i=0;i<n; i++){ arr[i]=sc.nextInt(); } int mx=Integer.MIN_VALUE; for(int i=0; i<n; i++){ mx=Math.max(mx,arr[i]); } System.out.println("maximum element is="+mx); } }
Output