Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class Max {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter number of elements");
- int n = Integer.parseInt(sc.nextLine());
- int []newArray = new int[n];
- for (int i = 0; i < n; i++) {
- newArray[i] = Integer.parseInt(sc.next());
- }
- int max = newArray[0];
- for (int i = 0; i < newArray.length; i++) {
- if (max < newArray[i]) {
- max = newArray[i];
- }
- }
- System.out.println("The max number is " + max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement