- method with a type parameter
- independent of a generic class
- can be used in a non-generic class
- can be used in a generic class with a different type parameter
public class myClass
{
public
{
System.out.println(x);
}
}
- syntax for calling the method
m.
m.
Inheritance
- inheritance is allowed with generics
{
}
public class Child
{
public class A {...}
public class myGeneric
myGeneric//these two have
myGeneric//No Relationship
ArrayList
Create an array of 5 Strings using ArrayList
ArrayList
//
- Array
- ArrayList
- ArrayList
myList = new ArrayList (5) - myList.set(3,"hello")
- String b = myList.get(2);
- int len = myList.size()
- Both Indexes start at zero
myList.add("x"); // size is now 1
myList.add("y"); // puts y at index 1, size is now 2
No comments:
Post a Comment