Refine search
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)); } }
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); }
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 } } } }
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");
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());
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));
/** * 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; }
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);
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))); } }
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); }
@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); }
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));
/** * 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; }
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); }
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));