Java Algebra