Re: generics: how to tell more about the parameter?



Mikhail Teterin wrote:
Hi!

I'd like to promise certain things about the parameter of a generic:

public class Foo<Bar implements Something> {
...
}

how about:

public class Foo<Bar extends Something> {

Note that this works if `Something' is a class or if it is an interface.
--
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
.



Relevant Pages

  • program challenge
    ... public void setName{ ... the salaried class that extends Employee ... public class Salaried extends Employee ... // Programmer.java: the programmer class that extends from Hourly ...
    (comp.lang.java.help)
  • Re: Exceptions
    ... >> public abstract class BasePermissionException extends ... >> public abstract class BaseRulesException extends BaseRuntimeException ... >> public class PermissionException extends BasePermissionException ... > public class PermissionException extends RuntimeException ...
    (comp.lang.java.help)
  • Re: is it ok to return null?
    ... A refactoring to be aware of also is the "Introduce Null Object". ... The refactoring includes creating a Null Object that extends the original, ... public class TestEmployee extends TestCase ...
    (comp.lang.java.help)
  • A good way to approach this?
    ... public class AutoFillTextArea extends JTextArea implements CaretListener { ... caret. ...
    (comp.lang.java.gui)
  • Re: ADTs vs. interfaces
    ... >>mixture of abstract methods and concrete methods and your variables ... >>With an interface, it's a little different. ... you can't use extends from an interface. ... > public class BigBooks implements Books { ...
    (comp.lang.java.help)