Tabnine Logo
Collections.max
Code IndexAdd Tabnine to your IDE (free)

How to use
max
method
in
java.util.Collections

Best Java code snippets using java.util.Collections.max (Showing top 20 results out of 4,212)

Refine searchRefine arrow

  • Collections.min
  • PrintStream.println
  • List.add
origin: stackoverflow.com

 import java.util.Arrays;
import java.util.Collections;

import org.apache.commons.lang.ArrayUtils;

public class MinMaxValue {

  public static void main(String[] args) {
    char[] a = {'3', '5', '1', '4', '2'};

    List b = Arrays.asList(ArrayUtils.toObject(a));

    System.out.println(Collections.min(b));
    System.out.println(Collections.max(b));
  }
}
origin: apache/hive

protected double maxNdvForCorrelatedColumns(List<JoinLeafPredicateInfo> peLst,
ImmutableMap<Integer, Double> colStatMap) {
 int noOfPE = peLst.size();
 List<Double> ndvs = new ArrayList<Double>(noOfPE);
 for (int i = 0; i < noOfPE; i++) {
  ndvs.add(getMaxNDVForJoinSelectivity(peLst.get(i), colStatMap));
 }
 return Collections.max(ndvs);
}
origin: stackoverflow.com

 public class NewClass4 {
  public static void main(String[] args)
  {
    HashMap<Integer,Integer>map=new HashMap<Integer, Integer>();
    map.put(1, 50);
    map.put(2, 60);
    map.put(3, 30);
    map.put(4, 60);
    map.put(5, 60);
    int maxValueInMap=(Collections.max(map.values()));  // This will return max value in the Hashmap
    for (Entry<Integer, Integer> entry : map.entrySet()) {  // Itrate through hashmap
      if (entry.getValue()==maxValueInMap) {
        System.out.println(entry.getKey());     // Print the key with max value
      }
    }

  }
}
origin: stackoverflow.com

 public class MaxList {
  public static void main(String[] args) {
    List l = new ArrayList();
    l.add(1);
    l.add(2);
    l.add(3);
    l.add(4);
    l.add(5);
    System.out.println(Collections.max(l)); // 5
    System.out.println(Collections.min(l)); // 1
  }
}
origin: googlesamples/android-Camera2Basic

    if (option.getWidth() >= textureViewWidth &&
      option.getHeight() >= textureViewHeight) {
      bigEnough.add(option);
    } else {
      notBigEnough.add(option);
  return Collections.min(bigEnough, new CompareSizesByArea());
} else if (notBigEnough.size() > 0) {
  return Collections.max(notBigEnough, new CompareSizesByArea());
} else {
  Log.e(TAG, "Couldn't find any suitable preview size");
origin: shopizer-ecommerce/shopizer

  sizeList.add(pack.getShippingHeight());
  sizeList.add(pack.getShippingLength());
  sizeList.add(pack.getShippingWidth());
  Double maxSize = (Double)Collections.max(sizeList);
  if(size==null || maxSize.doubleValue() > size.doubleValue()) {
    size = maxSize.doubleValue();
System.out.println(inputParameters.toString());
origin: org.apache.hadoop/hadoop-hdfs

RemoteEditLog bestLog = Collections.max(logGroup);
logs.add(bestLog);
origin: jersey/jersey

  public boolean contains(List<Integer> data) {
    if (Collections.min(data) < lower()
        || Collections.max(data) > upper()) {
      return false;
    } else {
      return true;
    }
  }
}
origin: go-lang-plugin-org/go-lang-idea-plugin

placeholders.add(state.toPlaceholder());
  int maxArgNum = Collections.max(state.argNums);
  if (argNum < maxArgNum) {
   argNum = maxArgNum;
origin: stackoverflow.com

 List<Float> myList = new ArrayList<Float>();

System.out.print("Please enter your first temperature");
myList.add(scan.nextFloat());
System.out.print("Please enter your second temperature");
myList.add(scan.nextFloat());
System.out.print("Please enter your third temperature");
myList.add(scan.nextFloat());

System.out.println(Collections.min(myList));
System.out.println(Collections.max(myList));
origin: yahoo/egads

/**
 * Creates a histogram of the provided data.
 * 
 * @param data list of observations
 * @param breaks number of breaks in the histogram
 * @return List of integer values size of the breaks
 */
public static List<Integer> getHistogram(List<Double> data, int breaks) {
  if (data.isEmpty()) {
    return Collections.emptyList();
  }
  List<Integer> ret = new ArrayList<Integer>(breaks);
  for (int i = 0; i < breaks; i++) {
    ret.add(0);
  }
  double min = Collections.min(data);
  double range = Collections.max(data) - min + 1;
  double step = range / breaks;
  for (double point : data) {
    // Math.min necessary because rounding error -> AIOOBE
    int index = Math.min((int) ((point - min) / step), breaks - 1);
    ret.set(index, ret.get(index) + 1);
  }
  return ret;
}

origin: stackoverflow.com

int startFrom = 2; // configurable number
 List<Integer> intList = Arrays.asList(1,2,1,3,2,1,4);
 List<Integer> sortedList =  new ArrayList<>();
 for (int i = 0; i < intList.size(); i++) {
   if(i < startFrom){
     sortedList.add(null);
     continue;
   }
   ArrayList<Integer> list = new ArrayList<Integer>(intList.subList(i -startFrom, i+1));
   sortedList.add(Collections.max(list));
 }
 System.out.println(sortedList);
origin: stackoverflow.com

 import java.util.*;

public class Main {

  public static Character[] convert(char[] chars) {
    Character[] copy = new Character[chars.length];
    for(int i = 0; i < copy.length; i++) {
      copy[i] = Character.valueOf(chars[i]);
    }
    return copy;
  }

  public static void main(String[] args) {
    char[] a = {'3', '5', '1', '4', '2'};
    Character[] b = convert(a);
    System.out.println(Collections.max(Arrays.asList(b)));
  }
}
origin: stackoverflow.com

List<Integer> list = Arrays.asList(100,2,3,4,5,6,7,67,2,32);
 int min = Collections.min(list);
 int max = Collections.max(list);
 System.out.println(min);
 System.out.println(max);
origin: apache/kylin

private void setupMapper(CubeSegment cubeSeg) throws IOException {
  // set the segment's offset info to job conf
  Map<Integer, Long> offsetStart = cubeSeg.getSourcePartitionOffsetStart();
  Map<Integer, Long> offsetEnd = cubeSeg.getSourcePartitionOffsetEnd();
  Integer minPartition = Collections.min(offsetStart.keySet());
  Integer maxPartition = Collections.max(offsetStart.keySet());
  job.getConfiguration().set(CONFIG_KAFKA_PARITION_MIN, minPartition.toString());
  job.getConfiguration().set(CONFIG_KAFKA_PARITION_MAX, maxPartition.toString());
  for(Integer partition: offsetStart.keySet()) {
    job.getConfiguration().set(CONFIG_KAFKA_PARITION_START + partition, offsetStart.get(partition).toString());
    job.getConfiguration().set(CONFIG_KAFKA_PARITION_END + partition, offsetEnd.get(partition).toString());
  }
  job.setMapperClass(KafkaFlatTableMapper.class);
  job.setInputFormatClass(KafkaInputFormat.class);
  job.setOutputKeyClass(BytesWritable.class);
  job.setOutputValueClass(Text.class);
  job.setOutputFormatClass(SequenceFileOutputFormat.class);
  job.setNumReduceTasks(0);
}
origin: nickbutcher/plaid

@Override
public void onDrawerOpened(View drawerView) {
  // scroll to the new item(s) and highlight them
  List<Integer> filterPositions = new ArrayList<>(sources.length);
  for (Source source : sources) {
    if (source != null) {
      filterPositions.add(filtersAdapter.getFilterPosition(source));
    }
  }
  int scrollTo = Collections.max(filterPositions);
  filtersList.smoothScrollToPosition(scrollTo);
  for (int position : filterPositions) {
    filtersAdapter.highlightFilter(position);
  }
  filtersList.setOnTouchListener(filtersTouch);
}
origin: stackoverflow.com

List<Integer> list = new ArrayList<>();
   List<String> stringList = new ArrayList<>();
   // Populate the lists
   for(int i=0; i<=10; ++i){
     list.add(i);
     String newString = "String " + i;
     stringList.add(newString);
   }
   // add another negative value to the integer list
   list.add(-1939);
   // Print the min value from integer list and max value form the string list.
   System.out.println("Max value: " + Collections.min(list));
   System.out.println("Max value: " + Collections.max(stringList));
origin: yahoo/egads

/**
 * Same as <code>getHistogram</code> but operates on <code>BigIntegers</code>.
 */
public static List<Integer> getHistogramBigInt(List<BigInteger> data, int breaks) {
  if (data.isEmpty()) {
    return Collections.emptyList();
  }
  List<Integer> ret = new ArrayList<Integer>(breaks);
  for (int i = 0; i < breaks; i++) {
    ret.add(0);
  }
  BigInteger min = Collections.min(data);
  BigInteger max = Collections.max(data);
  BigInteger range = max.subtract(min).add(BigInteger.valueOf(1));
  BigInteger step = range.divide(BigInteger.valueOf(breaks));
  if (step.equals(BigInteger.ZERO)) {
    return Collections.emptyList(); // too small
  }
  for (BigInteger point : data) {
    int index = point.subtract(min).divide(step).intValue();
    // Math.min necessary because rounding error -> AIOOBE
    index = Math.min(index, breaks - 1);
    ret.set(index, ret.get(index) + 1);
  }
  return ret;
}

origin: stackoverflow.com

 public static void main(String[] args) {
  Scanner scanner = new Scanner(System.in);
  List<Integer> list = new ArrayList<>();
  while (list.size() < 10 && scanner.hasNext()) {
    if (scanner.hasNextInt()) {
      list.add(scanner.nextInt());
    } else {
      scanner.next();
    }
  }
  Integer max = Collections.max(list);
  System.out.println(max);
}
origin: stackoverflow.com

ArrayList<String> dirNo = new ArrayList<String>();
 dirNo.add("1");
 dirNo.add("2");
 dirNo.add("3");
 dirNo.add("4");
 dirNo.add("5");
 dirNo.add("6");
 dirNo.add("7");
 dirNo.add("8");
 dirNo.add("9");
 dirNo.add("10");
 dirNo.add("11");
 Comparator<String> cmp = new Comparator<String>() {
   @Override
   public int compare(String o1, String o2) {
     return Integer.valueOf(o1).compareTo(Integer.valueOf(o2));
   }
 };
 System.out.println("max : " + Collections.max(dirNo, cmp));
java.utilCollectionsmax

Javadoc

Searches the specified collection for the maximum element.

Popular methods of Collections

  • emptyList
    Returns the empty list (immutable). This list is serializable.This example illustrates the type-safe
  • sort
  • singletonList
    Returns an immutable list containing only the specified object. The returned list is serializable.
  • unmodifiableList
    Returns an unmodifiable view of the specified list. This method allows modules to provide users with
  • emptyMap
    Returns the empty map (immutable). This map is serializable.This example illustrates the type-safe w
  • emptySet
    Returns the empty set (immutable). This set is serializable. Unlike the like-named field, this metho
  • unmodifiableMap
    Returns an unmodifiable view of the specified map. This method allows modules to provide users with
  • singleton
    Returns an immutable set containing only the specified object. The returned set is serializable.
  • unmodifiableSet
    Returns an unmodifiable view of the specified set. This method allows modules to provide users with
  • singletonMap
    Returns an immutable map, mapping only the specified key to the specified value. The returned map is
  • addAll
    Adds all of the specified elements to the specified collection. Elements to be added may be specifie
  • reverse
    Reverses the order of the elements in the specified list. This method runs in linear time.
  • addAll,
  • reverse,
  • unmodifiableCollection,
  • shuffle,
  • enumeration,
  • list,
  • synchronizedMap,
  • synchronizedList,
  • reverseOrder,
  • emptyIterator

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • findViewById (Activity)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now