• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I was expecting Unreachable statement

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You it was fast
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mahtab Alam wrote:Thank You it was fast

You're welcome!
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic