I want to display a graph and for displaying that i need integer values.I get this from my code
    Collection c = Sort.values();
Is there any way that i convert collection in such a way that i get integer values?i get this when i print the collection c
    [64770, 26529, 13028, 848, 752, 496]
                The question was: conversion to int arrayInteger[] can not be assigned to int[] or vice versa
int[] array = c.stream().mapToInt( i -> i ).toArray();
                        Assuming the values are of type Integer, you can try this:
Collection c = Sort.values();
Integer[] a = (Integer[])(c.toArray(new Integer[c.size()]));
                        for (Integer value : c) {
    int i = value.intValue();
    //do something with either value or i
}
                        Simply:
Integer[] yourArrayVar = yourCollectionVar.toArray(new Integer[0]);
java just needs to know what kind of array to produce.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With