2013年11月2日星期六

Why not compile java code phrase through

BufferedReader in = new BufferedReader(new FileReader(fileName));

while ((String str = in.readLine())!=null) {

}

------ Solution ------------------------------------- -------


while ((String str = in.readLine ())! = null) in
executed first in.readLine () to get the results
then assign the result to str
The scope is str (String str = in.readLine ()) brackets, this bracketed value str
out of the brackets str be recycled . .

------ For reference only ---------------------------------- -----

String str;
while (( str = in.readLine())!=null) {



------ For reference only --------------------------- ------------
scope of local variables issues now

------ For reference only ---------------------------------- -----
code stickers multi-point , as well , the compiler does not pass error is which ? These two lines of code all given?
------ For reference only -------------------------------------- -

+1
java is not defined more than once with the same name variable
------ For reference only ------------------------ ---------------
can only say that a long exposure , the statement or on the outside of the loop is good !
------ For reference only -------------------------------------- -
grammatical problems while in the Shashi Hou can define things
------ For reference only -------------- -------------------------
like if ((int a = 0) == 0) {} this syntax is wrong , not a scope issue !
------ For reference only ---------------------------------------
above also variable scoping it, = number you can use it on the left is not an expression . Joe Smith is equal to John Doe . Can you say what Joe Smith John Doe at dinner equal
------ For reference only -------------------- -------------------
learn
String str = in.readLine () is a statement that defines the variable
used to make a judgment is not enough
------ For reference only --------------------------- ------------

ah , this is the meaning
------ For reference only ---------------------------------------

+1   
java can not define multiple variables with the same name  

+1
------ For reference only -------------------------------- -------

  
while ((String str = in.readLine ())! = null) in   
executed first in.readLine () to get the results   
then assign the result to str   
The scope is str (String str = in.readLine ()) brackets, this bracketed value str   
out of the brackets str be recycled . .   
 

+1. preferably define variables on the outside . ,
------ For reference only ------------------------------------- -

discussed above, so many people , I say individual bar !
landlord did not try / catch, maybe because of this

没有评论:

发表评论