java

JVM Stacks and Stack Frames alvin May 29, 2017 - 11:14am

For functions without deep levels of recursion, there’s nothing wrong with the algorithms shown in the previous lessons. I use this simple, basic form of recursion when I know that I’m working with limited data sets. But in applications where you don’t know how much data you might be processing, it’s important that your recursive algorithms are tail-recursive, otherwise you’ll get a nasty StackOverflowError.

For instance, if you run the sum function from the previous lessons with a larger list, like this:

A ‘printf’ format reference page (cheat sheet)

Summary: This page is a printf formatting cheat sheet. I originally created this cheat sheet for my own purposes, and then thought I would share it here.

A cool thing about the printf formatting syntax is that the specifiers you can use are very similar, if not identical, between several different languages, including C, C++, Java, Perl, Ruby, and others, so your knowledge is reusable, which is a good thing.

How to install Java, Scala, and SBT on Linux Mint alvin May 19, 2017 - 7:27pm

Lately I’ve been in the process of “making the switch” from macOS to Linux Mint, and to that end, I just installed the Java 8 JDK/SDK, Scala 2.12, and SBT 0.13 on a new Linux Mint system, and I want to note here how I did that while it’s still fresh in my mind. Here are my notes in a compact form.

Functional programming: Everything is immutable alvin May 6, 2017 - 12:38pm

“Remember how weird it seemed when you first learned that a String in Java was immutable? Well, in functional programming it’s all like that. Everything is immutable.”

(From a discussion with a Java developer recently.)

How to get cleaned HTML as a String from HTMLCleaner alvin March 11, 2017 - 2:35pm

If you ever need to get the “cleaned” HTML as a String from the Java HTMLCleaner project, I hope this example will help:

IntelliJ IDEA: Keystrokes I commonly use on MacOS (OS X) alvin March 6, 2017 - 6:26pm

As a quick note, this is a list of the IntelliJ IDEA keystrokes I use on my MacOS systems:

How to search multiple jar files for a string or pattern (shell script)

Here’s a Unix shell script that I use that search Java “jar” files for any type of pattern. You can use it to search for the name of a class, the name of a package, or any other string/pattern that will show up if you manually ran jar tvf on each jar file. The advantage of this script — if you’re a Unix, Linux, or Cygwin user — is that it will search through all jar files in the current directory:

Scalasti, a Scala interface to the StringTemplate Java template library alvin February 15, 2017 - 10:57am

I use the Java StringTemplate library in my Android applications, and Brian Clapper has created a Scala wrapper around it that he calls Scalasti. His intro: “Scalasti is a Scala interface to the StringTemplate Java template library. It provides a subset of the features of StringTemplate, using a more Scala-friendly syntax.”