Is is acceptable in java to declare and type variables inside a while loop? This from Chapter 7 code:
Code:
if (toDoListCursor.moveToFirst())
do {
String task = toDoListCursor.getString(ToDoDBAdapter.TASK_COLUMN);
long created = toDoListCursor.getLong(ToDoDBAdapter.CREATION_DATE_COLUMN);
ToDoItem newItem = new ToDoItem(task, new Date(created));
todoItems.add(0, newItem);
} while (toDoListCursor.moveToNext());
aa.notifyDataSetChanged();
Should not
Code:
String task; long created; ToDoItem newItem;
appear before the loop and then just assignments made inside the loop? Seems like the loop will be creating hundreds of variables this way, unless Java somehow manages that automatically.