From reading the Oracle docs regarding primitive default initialization, local variables (method variables) are not given a default value. Is that why:
    for(int k; k<0; k++) 
is incorrect? Is a for loop considered a method?
			
			
									
									
						About Question enthuware.ocajp.i.v8.2.891 :
Moderator: admin
- 
				jamesmccreary
 - Posts: 22
 - Joined: Sun Jan 15, 2017 10:51 pm
 - Contact:
 
- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.891 :
No, for loop is not considered a method. But the variable defined in a for loop is a local variable with scope limited to just the for loop body. So it is not given a default value.
			
			
									
									
						- 
				jamesmccreary
 - Posts: 22
 - Joined: Sun Jan 15, 2017 10:51 pm
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.891 :
Thank you for the clarification!
			
			
									
									
						Who is online
Users browsing this forum: No registered users and 14 guests