aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I was expecting Unreachable statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "I was expecting Unreachable statement" Watch "I was expecting Unreachable statement" New topic
Author

I was expecting Unreachable statement

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 172



Mahtab Alam (OCJP )
Blogs : alamsql.blogspot.in , alammahtab.blogspot.in
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

The compiler doesn't examine the contents of a method you're calling to decide whether it will ever return or not. As far as the compiler is concerned you call go(), and then print something out. To get an "unreachable statement" error you need it to be clear just by looking at static details of the method in question that it will never get there.
Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 172

Thank You it was fast
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

Mahtab Alam wrote:Thank You it was fast

You're welcome!
Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 172



class A<T>
{

public <K> A<? super K> get(){return new A();}

}

It compiles fine although with one warning
I thought it will not compile .
How can a return type of A be assigned to A<? super K> .
So only possible assignment for A<? super K> should be

A<? super K> K and super type of K.And since K extends Object.
How is it Ok
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I was expecting Unreachable statement
 
Similar Threads
Assertions
Exception handling problem
Unreachable statements
What is this() method
Thinking in Java problem