print the largest element in array java program | java array program #coding #java #array

preview_player
Показать описание
#pythonprogramming #machinelearning #hacking #programminglife #coders #javaprogramming #web #codingisfun #datascience #programmerlife #javadeveloper #js #hacker #angular #reactjs #bhfyp #coderlife #sql #cybersecurity #developers #nodejs #o #codingmemes #webdesigner #programmerslife #codingbootcamp #informationtechnology #instagood #backend #frontend #java #python #javascript #programming #coding #html #programmer #developer #css #code #coder #php #software #computerscience #webdeveloper #webdevelopment #softwaredeveloper #codinglife #technology #linux #webdesign #android #indonesia #programmingmemes #tech #programmers #development #c #softwareengineer #computer
Рекомендации по теме
Комментарии
Автор

Instead of this try this one
int arr[]={3, 4, 7, 8, 2};
int max=arr[0];
for (int i=1;i<arr.length ;i++ ){
if (arr[i]>max) {
max=arr[i];
}
}
System.out.println(max);

ashutoshrai
Автор

As someone who just got into array based programming languages, it's insane how verbose Java is for this task compared to APL, BQN, or Uiua.

KayleLang
Автор

will work in case pf sorted array otherwise if array is not sorted will give wrong output.

mihiragrawal
Автор

Time complexity is O(n²). Make it O(n)

comrade_marshal
Автор

Bro can u tell me the use of i and j here like from where i starts and from where j ?

Sulakshit
Автор

Two loops are not required to find a max in an array

mytechhub
Автор

if this is a sorted array then this code will not work

shashikumar
Автор

This is more clear : int [] x = {12, 32, 43, 54, 65, 76, 99, 23, 36, 182};
int max = x[0];
for(int w : x){
max = Math.max(w, max);
}
System.out.println(max);

dashcamcompilationswithcomment
Автор

What if 89 is at the end
There j will be :
j = I + 1;
But at that time I + 1 doesn't exist😂

editIQYT