Is there a difference in what goes on between these two ways:
public void method() {
String data;
Node current = head;
while(current != null) {
data = current.getData();
// Do something with data
current = current.getNext();
}
}
and this:
public void method() {
Node current = head;
while(current != null) {
String data = current.getData();
// Do something with data
current = current.getNext();
}
}
I've never had a professor explain this before, and was wondering if there is a difference between the two and which one is "better" to use.