java - What exactly is <T> in the following method declaration? -


i'll admit parameterized classes , methods combined extends , super confuse heck out of me. said, appreciate if explain why following doesn't work, , direct me definitive guide understanding these things.

here's barebones coding of problem. in main class:

public class app {      public <t extends object> boolean isnull(t obj)     {         return obj == null;     }      public static void main(string[] args)     {      }  } 

in junit test class have:

import static org.junit.assert.assertequals;  import org.junit.assert.*; import org.junit.test;  public class testclass1 {     @test     public void shouldbenull()     {         app theapp = new app();         org.junit.assert.assertfalse(theapp.isnull(new string())); //eclipse flags line     } } 

eclipse warns me method isnull(string) undefined app. under impression in definition of isnull, i'm telling instance of t should regarded object, , since string object, should ok. that's not case. please enlighten me. thanks. , it's worth, added "extends object" modification original method definition thinking help, didn't. thousand thank you's whoever can make should obvious (but isn't), obvious.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

android - MPAndroidChart - How to add Annotations or images to the chart -