静态导入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反编译后,还是还原成用类名调用静态方法

最新文章

  1. spring入门(七)【springMVC返回json串】
  2. Mac ping localhost 地址变化
  3. 远程连接Oracle时出现ORA-01034 和ORA-27101 的解决办法
  4. JAVA thread0.interrupt()方法
  5. LeetCode:Substring with Concatenation of All Words (summarize)
  6. Qt写入txt文件方法
  7. MVC&amp;amp;&amp;amp;MVP
  8. grant授权“失败”的原因
  9. Global build settings
  10. 学生管理系统开发代码分析笔记:jsp+java bean+servlet技术
  11. git恢复误删除文件
  12. switch and checkbox
  13. pycharm导入自己写的.py文件时,模块下方出现红色波浪线解决
  14. Oracle课程档案,第七天
  15. proposal-cancelable-promises
  16. 代码控制打电话、发短信、发邮件、打开手机app等操作
  17. cxListView和dbgrid联动
  18. oracle数据库基础功能
  19. LAB3 整数相加
  20. CAS和Synchronized

热门文章

  1. POJ 3422 Kaka&#39;s Matrix Travels(拆点+最大费用流)题解
  2. 【联网】虚拟机下Linux(终端)配置网络的方法
  3. Anaconda ubuntu16.04 Cuda 8.0安装pytorch
  4. nodejs v8引擎
  5. BZOJ 2806 【CTSC2012】 Cheat
  6. springMVC中不通过注解方式获取指定Service的javabean
  7. Android之微信支付
  8. 牛客网——C列一列
  9. hdu 3687 10 杭州 现场 H - National Day Parade 水题 难度:0
  10. redux中的compose源码分析