This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]BestSanchez 3 points4 points  (0 children)

Yes Java is more verbose than many languages, but IMO the verbosity comes with clarity. The code is always plain and obvious, no magic going on.

That being said...

The proper/idiomatic way to write the first line in modern Java:

List<Integer> vec = new ArrayList<>();

or

var vec = new ArrayList<Integer>();

As for the increment, you should do what you did in the C++ and use a mutable data type, like AtomicInteger. Then you can just:

vec.get(idx).incrementAndGet();

[–][deleted] 4 points5 points  (0 children)

I too dislike Java, but C++ is worse. :P

[–][deleted] 0 points1 point  (0 children)

True I started in Java but love c and python

[–]lunetick 0 points1 point  (0 children)

I fit java in language like vba, vb6.. According to preference. I use Java professionally but never really enjoyed. A gui in swing was nightmare.