Java语言一元运算符实例解析
作者:邹邹wl 时间:2023-01-14 15:31:22
一元运算符,也叫单项算符,一目运算符,一元算符 ,英文名字:UnaryOperator。
描述:接受一个参数为类型T,返回值类型也为T。
源码:
public interface UnaryOperator<T> extends Function<T, T> {
/**
* Returns a unary operator that always returns its input argument.
*
* @param <T> the type of the input and output of the operator
* @return a unary operator that always returns its input argument
*/
static <T> UnaryOperator<T> identity() {
return t -> t;
}
}
测试代码:
@Test
public void test(){
super.print(UnaryOperator.identity().apply(1));//输出1
super.print(UnaryOperator.identity().apply(false));//输出false
super.print(UnaryOperator.identity().apply("string"));//输出string
}
来源:http://blog.csdn.net/z345434645/article/details/53876578
标签:java,一元运算符
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#使用Selenium+PhantomJS抓取数据
2022-09-13 23:18:02
![](https://img.aspxhome.com/file/2023/4/96354_0s.png)
Unity shader实现高斯模糊效果
2023-11-17 20:23:45
![](https://img.aspxhome.com/file/2023/4/102184_0s.jpg)
SpringBoot项目创建使用+配置文件+日志文件详解
2023-11-20 12:49:43
![](https://img.aspxhome.com/file/2023/9/59509_0s.jpg)
MyBatis-Plus实现逻辑删除的示例代码
2022-05-14 06:12:35
SpringBoot整合activemq的案例代码
2023-11-06 18:41:37
![](https://img.aspxhome.com/file/2023/9/58589_0s.png)
android使用DataBinding来设置空状态
2022-02-06 22:28:35
![](https://img.aspxhome.com/file/2023/4/88344_0s.gif)
浅入浅出的讲解Spring循环依赖问题
2023-11-03 07:16:11
![](https://img.aspxhome.com/file/2023/5/79285_0s.png)
MyBatis Plus插件机制与执行流程原理分析详解
2021-10-09 20:53:48
![](https://img.aspxhome.com/file/2023/5/77155_0s.jpg)
springboot异常处理的基本规范
2023-11-23 15:48:19
![](https://img.aspxhome.com/file/2023/8/59488_0s.png)
JavaWeb 中Cookie实现记住密码的功能示例
2023-04-06 05:06:48
![](https://img.aspxhome.com/file/2023/2/69102_0s.png)
Android编程实现禁止系统锁屏与解锁亮屏的方法
2022-05-21 02:35:39
举例解析Java的图像缓冲技术的使用
2022-09-08 17:17:17
c# Newtonsoft 六个值得使用的特性(下)
2022-02-18 11:38:32
![](https://img.aspxhome.com/file/2023/1/116571_0s.png)
Spring boot外部配置(配置中心化)详解
2022-07-11 23:13:26
详解Spring Boot 项目部署到heroku爬坑
2021-05-28 06:21:07
![](https://img.aspxhome.com/file/2023/0/106140_0s.png)
C#开启线程的四种示例
2022-06-01 13:04:37
Java通过PropertyDescriptor反射调用set和get方法
2023-10-11 19:34:17
springcloud之自定义简易消费服务组件
2022-01-29 00:18:24
![](https://img.aspxhome.com/file/2023/8/61878_0s.png)
C#中的延时函数sleep
2022-08-05 13:16:49
Springboot下RedisTemplate的两种序列化方式实例详解
2021-09-11 11:48:47
![](https://img.aspxhome.com/file/2023/6/87346_0s.png)