Java logic