aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes About switch... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "About switch..." Watch "About switch..." New topic
Author

About switch...

Rashmi Tambe
Ranch Hand

Joined: Aug 07, 2001
Posts: 418
Have a look at following code...

at line marked as 1 , compiler complains as
variable k might not have been initialised
I don't understand why?? if k is not visible to case 3 block , it should have given the error...
variable k undefined.
And if it is visible (in scope on case 3 block) then k is initialised , then why the the copiler complains...
thanx in advance.
Rashmi
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
k would be initialized only the switch statement hits the case2 and k is a local variable so it does not get initialized auto.
------------------
Have a nice day, Unless you've made other plans.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About switch...