Variable Is Not Updated Inside Loop Java