Why would anyone want to use an undefined variable? What is its purpose in a Java project?


There are a number of reasons to declare variables uninitialized. Here is a very simple pseudocode example of one

int a = 5;
int b = 10;
int temp;

temp = a;
a = b;
b = temp;

We used the uninitialized variable temp as a placeholder to swap a and b’s values
temp never really needed a definition


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.