java

recent posts related to java, jdbc, spring, etc.

A Java tuple class

After working with Scala for a long time, I had to come back to Java for a while to work on an Android app. Right away I missed a lot of things from the Scala world, including all of the built-in Scala collection methods, and other things as simple as the Scala Tuple classes.

If you haven’t used them before, a Scala Tuple class lets you write code like this:

A Java method to determine if an integer is between a range

Last night I was writing some code for my Android football game, and decided it would be best if I had a between method, so I could write some code like this to show that I wanted to test to see if a number was between an integer range:

if (between(distance, 8, 10)) { ...

That could would be interpreted as, “If the distance is between the values 8 and 10, do whatever is in the code block.” (I can make that code more readable in Scala, but in Java I think that’s the best I can do.)

An Easy Rules example (a Java "rules engine")

I’m considering using Easy Rules as a simple “rules engine” in my Android Football Game application, primarily because (a) there are a ton of “rules” involved in having the computer call offensive and defensive plays, and (b) I’m trying to find a way to simplify that code and make it more maintainable.

The Easy Rules website has a Hello, world demo you can look at to get started, but after that, here is my example.

Java int, double, float, and mixed type division rules

Problem: Java arithmetic involving mixed data types

While working on a math problem in Java just a little while ago, I realized that I wasn’t comfortable with the Java mixed-type division rules. That is, I wondered if the result of this equation:

3 / 2

the same as the result of this equation:

3 / 2.0

or this equation:

3.0 / 2.0

AlPad - A simple "scratchpad" editor

Over the course of a few hours this past week I created a little “scratchpad” text editor I named AlPad. It’s gone through several names, but since I’m just writing it for me, the name seems appropriate.

It’s not really correct to call AlPad an “editor”; it’s really just an app where I can keep a collection of miscellaneous notes I usually make when I’m working. It has very few features, just some ones I want and can implement easily:

Syndicate content