在Eclipse里静态导入
2024-08-27 11:31:03
静态导入import static 介绍见import static和import的区别
在Eclipse里配置静态导入,步骤见下面截图的箭头
例如导入下面的jar
常用的静态导入方法如下:
- com.google.common.base.Preconditions
- com.google.common.base.Predicates
- com.google.common.collect.Iterables
- com.google.common.collect.Lists
- com.google.common.collect.Maps
- com.google.common.collect.Sets
- org.apache.commons.lang.StringUtils
- org.junit.Assert
静态导入配置后,写代码只需要
package com.study.utils; import static com.google.common.base.Preconditions.checkArgument; public class L12 { public static void main(String[] args) {
int i = 9;
int j = 10;
checkArgument(i >= 0, "Argument was %s but expected nonnegative", i);
checkArgument(i < j, "Expected i < j, but %s > %s", i, j);
} }
class反编译后,还是还原成用类名调用静态方法
最新文章
- spring入门(七)【springMVC返回json串】
- Mac ping localhost 地址变化
- 远程连接Oracle时出现ORA-01034 和ORA-27101 的解决办法
- JAVA thread0.interrupt()方法
- LeetCode:Substring with Concatenation of All Words (summarize)
- Qt写入txt文件方法
- MVC&;amp;&;amp;MVP
- grant授权“失败”的原因
- Global build settings
- 学生管理系统开发代码分析笔记:jsp+java bean+servlet技术
- git恢复误删除文件
- switch and checkbox
- pycharm导入自己写的.py文件时,模块下方出现红色波浪线解决
- Oracle课程档案,第七天
- proposal-cancelable-promises
- 代码控制打电话、发短信、发邮件、打开手机app等操作
- cxListView和dbgrid联动
- oracle数据库基础功能
- LAB3 整数相加
- CAS和Synchronized
热门文章
- POJ 3422 Kaka&#39;s Matrix Travels(拆点+最大费用流)题解
- 【联网】虚拟机下Linux(终端)配置网络的方法
- Anaconda ubuntu16.04 Cuda 8.0安装pytorch
- nodejs v8引擎
- BZOJ 2806 【CTSC2012】 Cheat
- springMVC中不通过注解方式获取指定Service的javabean
- Android之微信支付
- 牛客网——C列一列
- hdu 3687 10 杭州 现场 H - National Day Parade 水题 难度:0
- redux中的compose源码分析