Skip to content

Commit 9950e89

Browse files
Update README.md
1 parent 5c048ac commit 9950e89

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5228,7 +5228,46 @@ public class Example {
52285228

52295229
</ul>
52305230

5231-
<h2><li>3. Sub Types </li></h2>
5231+
<h2><li>3. Raw Types And Sub Types </li></h2>
5232+
5233+
<ul>
5234+
<h3><i><ins>Raw Types:</ins></i> Raw types in Java Generics are a way to use a generic class or method without specifying its type parameters. Raw types are created by omitting the type parameter(s) from the generic class or method name.</h3>
5235+
5236+
<h3 align="Left">
5237+
5238+
```
5239+
import java.util.ArrayList;
5240+
import java.util.List;
5241+
5242+
public class Example <T extends List<Number>>{
5243+
public static <T>void printList(List<? super Number> list) {
5244+
for (Object o : list) {
5245+
System.out.println(o);
5246+
}
5247+
}
5248+
5249+
public static void main(String[] args) {
5250+
Example eg = new Example();
5251+
List<Number> li = new ArrayList<>();
5252+
li.add(1);
5253+
li.add(2);
5254+
eg.printList(li);
5255+
5256+
5257+
}
5258+
5259+
}
5260+
5261+
```
5262+
5263+
</h3>
5264+
5265+
<h3> <i> Here "Example eg = new Example();" is in raw type i.e. doesnot mention "Type" in " < > " operator. </i></h3>
5266+
5267+
<h3><i><ins>Sub Types:</ins></i> </h3>
5268+
5269+
</ul>
5270+
52325271

52335272
</ul>
52345273

0 commit comments

Comments
 (0)