Why does Java char use UTF-16?

Java used UCS-2 before transitioning over UTF-16 in 2004/2005. The reason for the original choice of UCS-2 is mainly historical: Unicode was originally designed as a fixed-width 16-bit character encoding. The primitive data type char in the Java programming language was intended to take advantage of this design by providing a simple data type that … Read more

Keycloak public client and authorization

As far as I understood, you have your frontend and backend applications separated. If your frontend is a static web-app and not being served by the same backend application (server), and your backend is a simple REST API – then you would have two Keycloak clients configured: public client for the frontend app. It would … Read more

Detecting the first iteration through a for-each loop in Java

One simpler way for this situation is to note that you can always append an empty string: // For the first iteration, use a no-op separator String currentSeparator = “”; for (String s : list) { builder.append(currentSeparator); builder.append(s); // From the second iteration onwards, use this currentSeparator = separator; } Alternatively (and preferrably) use Guava’s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)