Java

Java Basics: Class Constructor and Set Methods

Within the Java paradigm there is an idea of Getters and Setters.  The idea behind this is encapsulation… that is, to keep most of a class private, except for specific methods you want to expose. For example, consider you had a class called Broker.  Perhaps you don’t want all the elements in the class exposed, but you do want people to be able to get Broker names and set Broker names. ... »

Java Basics: Operator Order

In Java there is an order to how operators are evaluated. * (multiplication), / (division) and % (modulo) are evaluated first. + (addition) and – (subtraction) are evaluated next. = (assignment) is evaluated last. When there are multiple operators that would evaluated at the same time, they are picked in order from left to right. For example: answer = ab%c – d/e+f would be resolved in ... »

Java Basics: Data Hierarchy

The data hierarchy of java (from smallest to largest) is: Bits (or binary), which are values of 0 or 1. Characters, which are single values of numbers or letters (or Unicode characters.) Fields, which are composed of characters (more than one.) Records, which are several fields. File, which contains multiple records.   »

Java Basics: Abstraction & Interfaces

Java:Basics – Interfaces Like Python, Ruby and other languages, Java is big on inheritance. One can define functionality in a super class and extend that into sub classes (sub classes inheriting from the parent class.) Abstraction In Java, you can define a parent class as being abstract.  More than that, you can define the methods in the class as abstract as well.  This allows the methods to... »

Java: Infection Simulator

Awhile back I wrote a vampire infection sim in Python, as well as Groovy and Ruby.  Below is a simplified version written in Java. Concept The idea behind this simulator is to take a population of people and a virus infection.  To simplify the calculation we will generate stats on the strength of an individual human (member of the population) and the strength of the virus (viruencly.) The sim will... »