These are chat archives for Codewars/codewars.com/kata-solving-help

13th
Jul 2018
JomoPipi
@JomoPipi
Jul 13 2018 02:53
what does the message (java) mean:
Note: /workspace/java/src/solve.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
hobovsky
@hobovsky
Jul 13 2018 04:46
@JomoPipi it's java specific and not that trivial to explain, but more or less because all generics in Java are untyped down there at jvm implementation level, there's a possibility of type related problems (for example, Classcastexceptions) when you use untyped (raw) collections in code. But sometimes this warning difficult to avoid,especially when using 'old style' APIs which do not mix with generics well
And yeah, IMO type ellision was one of the worst decisions of Java designers :(
JomoPipi
@JomoPipi
Jul 13 2018 06:13

yeah, actually I noticed it appears if you use

List list = new ArrayList();

instead of

List list = new ArrayList<>();
hobovsky
@hobovsky
Jul 13 2018 06:26
In your example, the List list = .... part should also be typed: List<Something> list = new ArrayList<>();
JomoPipi
@JomoPipi
Jul 13 2018 07:50
ohh yeah I did type it
I meant to only show the difference with the <>
List<List<Set<Integer>>> list = new ArrayList<>();
proper?
Blind4Basics
@Blind4Basics
Jul 13 2018 07:51
seems so, yes
JomoPipi
@JomoPipi
Jul 13 2018 07:53
what's the best way for getting the element from a single set?
set.iterator().next() ?
*set with single element
Blind4Basics
@Blind4Basics
Jul 13 2018 07:55
ah, that part is really cumbersome, in java. I believe you cannot do better, but that's still slow because ti build the full Iterator object, iirc. Other possibility, but I doubt it will be better: set.stream().findAny()
JomoPipi
@JomoPipi
Jul 13 2018 07:56
oh ok... as long as it works
hobovsky
@hobovsky
Jul 13 2018 08:11
for treeset it would be easy, just get lower bound - it should be efficient, I believe, as no iterators should be involved. But in general, yup, as B4B said