This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
if i declare a variable but do not initialize it, java supplies a defaut. for reference variables it is assigned null.
ok, so why does the compiler complain that variable url might not be initialized?
i have to change it to
URL url = null;
is it because it is a local variable not a member variable?
A local variable (§14.4, §14.14) must be explicitly given a value before it is used, by either initialization (§14.4) or assignment (§15.26), in a way that can be verified using the rules for definite assignment (§16).
so, the answer is yes, it is because it is a local variable