Open Pankaj-Str opened 11 months ago
public class LargestElement{
public static void main(String[] args) { double[] arrays = {45.8, 1000.0, -90.3, -1000.0, 200.9}; double largest = arrays[0];
for (int i=0; i< arrays.length; i++){
if ( largest < arrays[i])
{
largest = arrays[i];
}
} System.out.println("Largest number in the Array is: " +largest); } }
public class largestelement{
public static void main(String[] args){
int[] array ={15,89,8,26,33};
int max= array[0];
for(int i=1;i<array.length;i++){
if(array[i]>max){
max=array[i];
}
}
System.out.println("The largest element in the array is: "+max);
}
}
public class Main { public static void main(String[] args) {
int[] numbers = {10, 25, 50, 5, 35, 75};
int max = numbers[0];
for (int i = 1; i < numbers.length; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
}
System.out.println("The largest element in the array is: " + max);
}
}
public class main { public static void main(String[] args) { int[] arr = {10, 5, 20, 8, 15};
}