validation for java input