Java tutorial
//package com.java2s; public class Main { public static int index(int bar, int beat) { if (beat == 1) { return bar * 2; } else if (beat == 5) { return bar * 2 + 1; } throw new IllegalArgumentException("only beats 1 and 5 allowed, but was " + beat); } }