What does (angle brackets) mean in Java?

后端 未结 6 1641
轮回少年
轮回少年 2020-11-22 05:12

I am currently studying Java and have recently been stumped by angle brackets(<>). What exactly do they mean?

public class Pool{
    public inter         


        
6条回答
  •  心在旅途
    2020-11-22 05:59

    It is related to generics in java. If I mentioned ArrayList that means I can add only String type object to that ArrayList.

    The two major benefits of generics in Java are:

    1. Reducing the number of casts in your program, thus reducing the number of potential bugs in your program.
    2. Improving code clarity

提交回复
热议问题