자바 max()

1 개요[ | ]

Java max()
자바 max()
import java.util.Arrays;
import java.util.Collections;
public class Main {
    public static void main(String args[]) {
        Double[] nums = {3.14, 77.7, 5.0, -10.5, -4.4};
        Double max = Collections.max(Arrays.asList(nums));
        System.out.println( max ); // 77.7
    }
}
public class Main {
    public static void main(String args[]) {
        double[] nums = {3.14, 77.7, 5.0, -10.5, -4.4};
        double max = nums[0];
        for(double i:nums)if(max<i)max=i;
        System.out.println( max ); // 77.7
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}