[Java] Program example to get the maximum and minimum values from an array

import java.util.*;

class Main{
public static void main(String[] args) {

    int[] data = {1,2,3,4,5,6,7,8,9,10};
    int Max = data[0];
    int Min = data[0];
    
    for(int i = 1 ; i < a.length; i++){
        if(Max < data[i]){
            Max = data[i];
            }else if(Min > data[i]{
            Min = data[i];
             }
        }
        System.out.println(Max);
    }
}

Recommended Posts

[Java] Program example to get the maximum and minimum values from an array
Get attributes and values from an XML file in Java
[Swift5] How to get an array and the complement of arrays
[Java] How to convert from String to Path type and get the path
[Java] Get a random value from an array
Output the maximum value from the array using Java standard output
[Java] How to get the maximum value of HashMap
Find the maximum and minimum values out of the 5 numbers entered in Java (correction ver)
Get to the abbreviations from 5 examples of iterating Java lists
Difficult to handle minimum values for Java8 LocalDateTime and Java6 Date
A program (Java) that outputs the sum of odd and even numbers in an array
A program that outputs a number greater than or equal to the input integer and a number less than the input integer from an array with 50 elements.
[Java] Declare and initialize an array
The road from JavaScript to Java
[Java] Conversion from array to List
Note No. 1 "Counting and displaying duplicate values in an array" [Java]
[Java] Shallow copy and deep copy when converting an array to List
From fledgling Java (3 years) to Node.js (4 years). And the impression of returning to Java
How to get the length of an audio file in java
Update JAVA to the latest version to 1.8.0_144 (when downloading from the web and updating)
[Java] How to get the current date and time and specify the display format
Compare the elements of an array (Java)
[Java] How to get the current directory
Get the type of an array element to determine if it is an array
Java: How to send values from Servlet to Servlet
[Ruby] Get unique elements from an array
How to get the date in java
Find the maximum and minimum of the five numbers you entered in Java
I translated the grammar of R and Java [Updated from time to time]
[Java8] Search the directory and get the file
How to create your own annotation in Java and get the value
[Ruby] I want to make an array from a character string with the split method. And vice versa.
[Swift] How to get the number of elements in an array (super basic)
[Java] Get and display the date 10 days later using the Time API added from Java 8.
Sample code to get the values of major SQL types in Java + MySQL 8.0
[Java] From two Lists to one array list
[Java] How to use Thread.sleep to pause the program
[Java] How to get and output standard input
How to get Class from Element in Java
[Java] Get multiple values from one return value
How to get and study java SE8 Gold
[Android] Get random keys and values from HashMap
[Java] How to get the redirected final URL
[Java] How to get the authority of the folder
Get the value from the array and find out what number it is included in
[Java] How to get the key and value stored in Map by iterative processing
When inserting from Java to MySQL, get Auto_Increment_ID (automatic numbering value) as the return value
[Java] How to get the URL of the transition source
Convert Java enum enums and JSON to and from Jackson
[Java] I want to calculate the difference from the date
How to write Scala from the perspective of Java
Convert the array of errors.full_messages to characters and output
[Java] How to extract the file name from the path
Java language from the perspective of Kotlin and C #
Source used to get the redirect source URL in Java
How to output standard from an array with forEach
Java classes and instances to understand in the figure
Using the database (SQL Server 2014) from a Java program 2018/01/04
Reverse Enum constants from strings and values in Java
[Ruby] How to get the tens place and the ones place
Gzip-compress byte array in Java and output to file