Skip to content

Instantly share code, notes, and snippets.

@msh01
Last active February 10, 2018 02:16
Show Gist options
  • Save msh01/5d89c120c7cb5c1c52351d81e2977733 to your computer and use it in GitHub Desktop.
Save msh01/5d89c120c7cb5c1c52351d81e2977733 to your computer and use it in GitHub Desktop.

java的泛型又被称为约束 以前不太明白为什么这么称呼,在实际的封装项目通用方法的过程中,发现约束这个称呼,真的是一语道尽泛型的妙用:

有时会在类上面声明泛型,然而在类上面声明的泛型不是约束类本身的。而是通过约束这个类,达到约束类里面各个属性和函数的目的,使类里面的属性的类型能 由外部加以控制,函数参数的参数类型能够从外部加以控制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment