Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

find max value in list python

mylist = [1, 7, 3, 12, 5]

min_value = min(mylist)
max_value = max(mylist)
Comment

find location of max value in python list

>>> m = max(a)
>>> [i for i, j in enumerate(a) if j == m]
[9, 12]
Comment

Get Max Value Element From List With Objects

public static void main(String[] args) {
	
        Employee em = new Employee("Kiro",33,"Bulgaria"); //Creating objects
        Employee em2 = new Employee("Pesho",35,"Bulgaria");
        Employee em3 = new Employee("John",39,"UK");
        Employee em4 = new Employee("Mike",53,"USA");

        Cafe cafe = new Cafe("Malibu",4); //Creating Cafe & add the objects
        cafe.addEmployee(em);
        cafe.addEmployee(em2);
        cafe.addEmployee(em3);
        cafe.addEmployee(em4);

        System.out.println("The oldest is: " + cafe.getOldestEmployee()); //prints 53
    }
}

public int getOldestEmployee(){

        int oldest = 0;

        if (this.employees.size() > 1){

            Optional<Employee> max = this.employees
                    .stream()
                    .max(Comparator.comparingInt(Employee::getAge));

            oldest =  max.get().getAge();

        }else if (this.employees.size() == 1){

            oldest = this.employees.get(0).getAge();
        }
        return oldest;
    }
Comment

PREVIOUS NEXT
Code Example
Java :: difference between string vs stringbuffer 
Java :: android dynamically create layer-list with item and shape site:stackoverflow.com 
Java :: seekbar thumb position 
Java :: last block incomplete in decryption 
Java :: why fields should be final in immutable class? 
Java :: java print data and check in android studio 
Java :: create a file in java in user home 
Java :: List Double, fixed size 
Java :: fog command minecraft 
Java :: java to python converter 
Java :: manifest merger 
Java :: java code for image encryption & decryption 
Java :: Arraylist imp for recursion 
Java :: reversing an integer with overflow handled 
Java :: spring code in java 
Java :: get cursor position in textarea java 
Java :: stream get double value from map 
Java :: change upper bar colour android studio 
Java :: num* num 
Java :: Java Program to Print Spiral Pattern of Numbers 
Java :: como detener un void java 
Java :: informaticapc 
Java :: combine .proto in android studio project 
Java :: grunt registertask multiple 
Java :: how to have multiple extensions in one filter java 
Java :: call method of another class without creating instance in java android 
Java :: java 8 if else in one statement 
Java :: ava program to add two numbers taking input from user 
Java :: spring media part max size 
Java :: Java take() Method 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =