Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

largest number in an array in java

public class LargestNum {
   
    public static void main(String[] args) {
        int arrayA[]={1,2,5,6,3,2,300,50,5000};  
        int arrayB[]={44,66,99,77,33,22,55};  
        System.out.println("Largest: "+caculateLargestNum(arrayA,arrayA.length));  
        System.out.println("Largest: "+caculateLargestNum(arrayB,arrayB.length));  
    }
  
        public static int caculateLargestNum(int[] array, int total){  
        int cal;  
        for (int i = 0; i < total; i++)   
                {  
                    for (int j = i + 1; j < total; j++)   
                    {  
                        if (array[i] >array[j])   
                        {  
                            cal =array[i];  
                            array[i] = array[j];  
                            array[j] = cal;  
                        }  
                    }  
                }  
               return array[total-1];  
        }  
       
}
Comment

PREVIOUS NEXT
Code Example
Java :: hashmap in java 
Java :: selection sort java 
Java :: save bitmap file for share on android 10 
Java :: sound file java 
Java :: thread java timer 
Java :: convert calendar to date java 
Java :: atm machine java project 
Java :: How to efficiently find the start node of a loop within a singly linked list, in Java? 
Java :: how to create xml file in java 
Java :: how to find sum of the digit of the numbers in java 
Java :: latest android version 
Java :: how to make popupwindow background blur in android 
Java :: activityViewModels 
Java :: uninstall java 
Java :: scala vs java 
Java :: get all enum values java 
Java :: java double to float 
Java :: java loops 
Java :: java how to change the length of an array 
Java :: java.lang.IllegalStateException: Could not obtain identifier 
Java :: android studio clock bar change color programmatically 
Java :: build libgdx jar 
Java :: how to convert a string of characters to a stream of binary characters binary 
Java :: bukkit console filter 
Java :: default java keystore 
Java :: Sending String from one activity to another 
Java :: set gamemode of player spigot 
Java :: How to initialize a 3d array in Java? 
Java :: string a int java 
Java :: vue input pre initial value 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =