+ 2
Is there a way to get wrapper classes in soloLearn
I'm asking this because when I try to make an Interger object it doesn't make one in the soloLearn ide, if not is there a way for me to make an arraylist of primitive objects in soloLearns ide in Java?
7 odpowiedzi
+ 1
// Interger x = 5; //typo Inte(r)ger
Integer x = 5;
0
ArrayList can't stores primitive int, but it can automatically convert int to Integer object as element.
Integer stores one primitive int.
ArrayList<Integer> list1 = new ArrayList<>(Arrays.asList(0,1,2,3,4,5));
list1.add(100);
System.out.println( list1 );
3th party libraries can store primitive int similar way
0
zemiak I know that but try making an Interger object in soloLearn it doesn't have it in the java library
0
Integer oi =100; // this ?
0
zemiak
Yeah it works in all ides but soloLearn must not have the entire java library because it outputs errors
https://code.sololearn.com/c3clzjW2rT9d/?ref=app
0
zemiak that is embarrassing, thanks
0
:-D