From charlesreid1

m (Replacing charlesreid1.com:3000 with git.charlesreid1.com)
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:


Trying to do one of the simplest operations imaginable: given a set of integers, find a duplicate.
Trying to do one of the simplest operations imaginable: given a set of integers, find a duplicate.
Link to code: https://git.charlesreid1.com/cs/java/src/master/arrays/find-dupes/FindOne.java


To implement one of the solutions, you have to take the integers passed in and use them to access another array.  
To implement one of the solutions, you have to take the integers passed in and use them to access another array.  
Line 21: Line 23:


Java is like the language that keeps giving, and then saying, "but there's a catch."
Java is like the language that keeps giving, and then saying, "but there's a catch."
[[Category:Java]]

Latest revision as of 03:33, 9 October 2019

An enumeration of the things I don't like about Java.

typing in general

Not necessarily Java-specific, but using a typed language is like wearing a stuffy outfit with a too-tight collar - the compiler.

generic object templating

Trying to do one of the simplest operations imaginable: given a set of integers, find a duplicate.

Link to code: https://git.charlesreid1.com/cs/java/src/master/arrays/find-dupes/FindOne.java

To implement one of the solutions, you have to take the integers passed in and use them to access another array.

Oh, no. Java will have none of that.

  • Problems begin with just the very act of initializing data. This is your first warning.
  • Can we do Arrays.asList(1,2,3,3)? Nope.
  • Also, we can use generics <T> - but, not in a static context.
  • Also, we can define static methods that take a generic type <T>. But no arrays T[].
  • To way to initialize an all-zeros list of Integers.
  • No way to convert any primitive types to wrappers in one go.
  • No way to convert from PT int[] to Object type Integer[]

Java is like the language that keeps giving, and then saying, "but there's a catch."