long int mx = *max_element(A.begin(),A.end()); in java code example Example: max element in vector c++ auto max = *max_element(vector.begin(), vector.end());