java - 键入列表的第一个/第二个/第三个参数
问题描述
我正在考虑使用 List 作为元组,我想做类似的事情:
t.done(null, List.of(true, "some string");
有没有办法输入列表,所以第一个元素必须是布尔值,第二个元素必须是字符串?
解决方案
不知道为什么要为此使用列表。如果你认为一个专门的类太费力,你可以尝试使用Triple<L,M,R>
Apache commons-lang:
Triple<Boolean, String, String> test = Triple.of(true, "some string", "another string");
推荐阅读
- c++ - 计算蜗牛爬墙需要多少天
- android - FLAG_SUPPORTS_COPY 示例
- python - Python2 的评论很重要吗?
- javascript - 在 Google 表格中复制/粘贴的更快方法?
- sqlalchemy - 如何区分 SQLAlchemy 的 IntegrityError 的原因?
- android - 在 android 11 上,状态栏不会隐藏
- ios - 添加 Cloud Firestore 时,Flutter 应用程序不会在 ios 上构建
- android - Flutter 应用程序 Google 权限和/或代码签名问题
- c - 使用泰勒级数在 C 中找到 sin(x)
- google-cloud-platform - 将公共 aws route53 记录导出为私有云 DNS 记录