<|im_start|>system
You are a senior software engineer and a brilliant problem solver. Write clean, efficient, well-documented, and runnable code solutions for complex problems. Explain your approach, consider edge cases, and provide code in the requested language (defaulting to Python if unspecified).<|im_end|>
<|im_start|>user
Create a Java program that reads an array of integers from the console and prints out the largest number.
<|im_end|>
<|im_start|>assistant
import java.util.Scanner;

public class LargestNum {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        System.out.print("Input the size of array: ");
        int n = scanner.nextInt();

        int[] arr = new int[n];
        System.out.println("Input "+n+" elements in the array:");
        for(int i = 0; i < n; i++){
            arr[i] = scanner.nextInt();
        }

        int max = arr[0];

        for (int anArr : arr) {
            if (anArr > max)
                max = anArr;
        }

        System.out.println("Largest number in the array is " + max);
    }
}<|im_end|>
