当前位置: 首页 > news >正文

java.util.Optional

原文链接

文章目录

    • 1、Optional作用
    • 2、常用API
      • 构造相关
      • get / orElse / orElseGet / orElseThrow
      • isPresent / ifPresent
      • filter
      • map / flatMap
    • 3、源码翻译

1、Optional作用

  • 类位于:java.util.Optional
  • 臭名昭著的空指针异常是导致Java应用程序失败的最常见原因;以前为了解决空指针异常,Google公司著名的Guava项目引入了Optional类,Guava通过使用检查空值的方式来防止代码污染,它鼓励程序员写更干净的代码;受到Google Guava的启发Optional类已经成为Java 8类库的一部分
  • Optional实际上是个容器,它可以保存类型T的值,或者仅仅保存null,Optional提供很多有用的方法,这样我们就不用显式进行空值检测
  • JDK8在线源码英文文档:https://nowjava.com/readcode/jdk8
  • JDK8在线源码中文文档:https://www.matools.com/api/java8

2、常用API

构造相关

        // 空值实例Optional<Object> empty = Optional.empty();// 非空值实例Optional<String> nonEmpty = Optional.of("123");// 可空值实例Optional<Object> maybeEmpty = Optional.ofNullable(null);

get / orElse / orElseGet / orElseThrow

        Optional<Object> empty = Optional.empty();// get方法遇到空值会抛出异常NoSuchElementExceptionObject o = empty.get();// 如果存在,则返回值,否则返回传入的默认值Object orElse = empty.orElse("123");System.out.println(orElse);//123// 如果存在,则返回该值,否则返回 Supplier.get()的返回值Object orElseGet = empty.orElseGet(new Supplier<Object>() {@Overridepublic Object get() {return "abc";}});System.out.println(orElseGet);//abctry {// 如果存在,返回该值,否则抛出异常(此异常是Supplier.get()返回的)Object o = empty.orElseThrow(new Supplier<Throwable>() {@Overridepublic Throwable get() {return new NullPointerException();}});} catch (Throwable e) {throw new RuntimeException(e);}

isPresent / ifPresent

        // 判断值是否存在System.out.println(empty.isPresent());// false// 有值才会执行accept方法empty.ifPresent(new Consumer<Object>() {@Overridepublic void accept(Object o) {//System.out.println(o.hashCode());}});

filter

        Optional<String> s = Optional.of("11");// 如果存在值,并且该值与Predicate.test()匹配,则返回描述该值的Optional,否则返回空值的OptionalOptional<String> s1 = s.filter(new Predicate<String>() {@Overridepublic boolean test(String s) {return false;}});System.out.println(s1);// Optional.empty

map / flatMap

  • map:apply返回的是Optional包装的值
  • flatMap:apply方法返回是Optional
// map处理Optional<Object> optiona4 = Optional.ofNullable("abc");Optional<Object> o4 = optiona4.map(new Function<Object, Object>() {@Overridepublic Object apply(Object o) {System.out.println(o);//abcreturn "123";}});System.out.println(o4.get());//123// flatMap处理Optional<Object> optiona5 = Optional.ofNullable("efg");Optional<String> optiona6 = optiona5.flatMap(new Function<Object, Optional<String>>() {@Overridepublic Optional<String> apply(Object o) {System.out.println(o);//efgreturn Optional.of("456");}});System.out.println(optiona6.get());//456

3、源码翻译

package java.util;import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;/*** A container object which may or may not contain a non-null value.* 一个可能包含也可能不包含非null值的容器对象* If a value is present, {@code isPresent()} will return {@code true} and* {@code get()} will return the value.* 如果存在值,isPresent()将返回 true,get()将返回该值。** <p>Additional methods that depend on the presence or absence of a contained* value are provided, such as {@link #orElse(Object) orElse()}* (return a default value if value not present) and* {@link #ifPresent(Consumer) ifPresent()} (execute a block* of code if the value is present).* 还提供了依赖于包含值是否存在的其他方法,例如 orElse(Object) orElse()(如果值不存在,则返回默认值)* 和 ifPresent(Consumer) ifPresent()(如果值存在,则执行代码块)。** <p>This is a <a href="../lang/doc-files/ValueBased.html">value-based</a>* class; use of identity-sensitive operations (including reference equality* ({@code ==}), identity hash code, or synchronization) on instances of* {@code Optional} may have unpredictable results and should be avoided.** 这是一个 value-based 的类;* 在Optional实例上的身份敏感操作(包括引用相等性==、标识哈希代码或同步)可能会产生不可预知的结果,应避免使用。** @since 1.8*/
public final class Optional<T> {/*** Common instance for {@code empty()}.* empty()的常见实例*/private static final Optional<?> EMPTY = new Optional<>();/*** If non-null, the value; if null, indicates no value is present* 如果非空,则为值;如果为 null,则表示不存在任何值*/private final T value;/*** Constructs an empty instance.* 构造一个空实例** @implNote Generally only one empty instance, {@link Optional#EMPTY},* should exist per VM.* 通常,每个 VM 只能存在一个空实例*/private Optional() {this.value = null;}/*** Returns an empty {@code Optional} instance.  No value is present for this* Optional.* 返回一个空的Optional实例。此Optional不存在任何值。** @apiNote Though it may be tempting to do so, avoid testing if an object* is empty by comparing with {@code ==} against instances returned by* {@code Option.empty()}. There is no guarantee that it is a singleton.* Instead, use {@link #isPresent()}.* todo 此处解释不是太明白,比较对象为空? 确保单例?* 尽管这样做可能很诱人,但请避免通过 == 与 Option.empty() 返回的实例来比较测试对象是否为空。* 不能保证它是单例。相反,请使用 isPresent()** @param <T> Type of the non-existent value* @return an empty {@code Optional}*/public static<T> Optional<T> empty() {@SuppressWarnings("unchecked")Optional<T> t = (Optional<T>) EMPTY;return t;}/*** Constructs an instance with the value present.* 构造一个有值的实例** @param value the non-null value to be present* @throws NullPointerException if value is null*/private Optional(T value) {this.value = Objects.requireNonNull(value);}/*** Returns an {@code Optional} with the specified present non-null value.** 返回具有指定的非空值的 Optional实例** @param <T> the class of the value* @param value the value to be present, which must be non-null 必须非空* @return an {@code Optional} with the value present* @throws NullPointerException if value is null*/public static <T> Optional<T> of(T value) {return new Optional<>(value);}/*** Returns an {@code Optional} describing the specified value, if non-null,* otherwise returns an empty {@code Optional}.* 返回描述指定值的 Optional实例,如果非 null,则返回空的Optional实例** @param <T> the class of the value* @param value the possibly-null value to describe 要描述的可能为空值* @return an {@code Optional} with a present value if the specified value* is non-null, otherwise an empty {@code Optional}*/public static <T> Optional<T> ofNullable(T value) {return value == null ? empty() : of(value);}/*** If a value is present in this {@code Optional}, returns the value,* otherwise throws {@code NoSuchElementException}.* 如果Optional里面有值,则返回该值,否则抛出异常NoSuchElementException** @return the non-null value held by this {@code Optional}* @throws NoSuchElementException if there is no value present** @see Optional#isPresent()*/public T get() {if (value == null) {throw new NoSuchElementException("No value present");}return value;}/*** Return {@code true} if there is a value present, otherwise {@code false}.* 如果存在值,则返回 true,否则返回 false** @return {@code true} if there is a value present, otherwise {@code false}*/public boolean isPresent() {return value != null;}/*** If a value is present, invoke the specified consumer with the value,* otherwise do nothing.* 如果存在值,则使用该值调用指定的使用者,否则不执行任何操作** @param consumer block to be executed if a value is present* @throws NullPointerException if value is present and {@code consumer} is* null 如果值存在且consumer为空 就会抛出异常*/public void ifPresent(Consumer<? super T> consumer) {if (value != null)consumer.accept(value);}/*** If a value is present, and the value matches the given predicate,* return an {@code Optional} describing the value, otherwise return an* empty {@code Optional}.* 如果存在值,并且该值与Predicate.test()匹配,则返回描述该值的Optional,否则返回空值的Optional** @param predicate a predicate to apply to the value, if present* @return an {@code Optional} describing the value of this {@code Optional}* if a value is present and the value matches the given predicate,* otherwise an empty {@code Optional}* @throws NullPointerException if the predicate is null*/public Optional<T> filter(Predicate<? super T> predicate) {Objects.requireNonNull(predicate);if (!isPresent())return this;elsereturn predicate.test(value) ? this : empty();}/*** If a value is present, apply the provided mapping function to it,* and if the result is non-null, return an {@code Optional} describing the* result.  Otherwise return an empty {@code Optional}.* 如果存在值,则对其应用提供的映射函数,如果结果为非 null,则返回描述结果的 {@code Optional}。* 否则不存在值,返回空值的Optional** @apiNote This method supports post-processing on optional values, without* the need to explicitly check for a return status.  For example, the* following code traverses a stream of file names, selects one that has* not yet been processed, and then opens that file, returning an* {@code Optional<FileInputStream>}:* 此方法支持对可选值进行后处理,而无需显式检查返回状态。* 例如,以下代码遍历文件名流,选择尚未处理的文件名流,然后打开该文件,返回Optional<FileInputStream>** <pre>{@code*     Optional<FileInputStream> fis =*         names.stream().filter(name -> !isProcessedYet(name))*                       .findFirst()*                       .map(name -> new FileInputStream(name));* }</pre>** Here, {@code findFirst} returns an {@code Optional<String>}, and then* {@code map} returns an {@code Optional<FileInputStream>} for the desired* file if one exists.* 在这里,findFirst返回一个Optional<String>,然后map返回所需文件的Optional<FileInputStream>(如果存在)。** @param <U> The type of the result of the mapping function* @param mapper a mapping function to apply to the value, if present* @return an {@code Optional} describing the result of applying a mapping* function to the value of this {@code Optional}, if a value is present,* otherwise an empty {@code Optional}* @throws NullPointerException if the mapping function is null*/public<U> Optional<U> map(Function<? super T, ? extends U> mapper) {Objects.requireNonNull(mapper);if (!isPresent())return empty();else {return Optional.ofNullable(mapper.apply(value));}}/*** If a value is present, apply the provided {@code Optional}-bearing* mapping function to it, return that result, otherwise return an empty* {@code Optional}.  This method is similar to {@link #map(Function)},* but the provided mapper is one whose result is already an {@code Optional},* and if invoked, {@code flatMap} does not wrap it with an additional* {@code Optional}.** 如果存在值,请对其应用提供的 {@code 可选} 轴承映射函数,返回该结果,否则返回空的 {@code 可选}。** 此方法类似于map,但提供的映射器的结果已经是 Optional,如果调用flatMap会用额外的Optional包装它。** @param <U> The type parameter to the {@code Optional} returned by* @param mapper a mapping function to apply to the value, if present*           the mapping function* @return the result of applying an {@code Optional}-bearing mapping* function to the value of this {@code Optional}, if a value is present,* otherwise an empty {@code Optional}* @throws NullPointerException if the mapping function is null or returns* a null result*/public<U> Optional<U> flatMap(Function<? super T, Optional<U>> mapper) {Objects.requireNonNull(mapper);if (!isPresent())return empty();else {return Objects.requireNonNull(mapper.apply(value));}}/*** Return the value if present, otherwise return {@code other}.* 如果存在,则返回值,否则返回入参other** @param other the value to be returned if there is no value present, may* be null* @return the value, if present, otherwise {@code other}*/public T orElse(T other) {return value != null ? value : other;}/*** Return the value if present, otherwise invoke {@code other} and return* the result of that invocation.* 如果存在,则返回该值,否则返回 Supplier.get()的返回值** @param other a {@code Supplier} whose result is returned if no value* is present* @return the value if present otherwise the result of {@code other.get()}* @throws NullPointerException if value is not present and {@code other} is* null*/public T orElseGet(Supplier<? extends T> other) {return value != null ? value : other.get();}/*** Return the contained value, if present, otherwise throw an exception* to be created by the provided supplier.* 如果存在,返回该值,否则抛出异常(此异常是Supplier.get()返回的)** @apiNote A method reference to the exception constructor with an empty* argument list can be used as the supplier. For example,* {@code IllegalStateException::new}** @param <X> Type of the exception to be thrown* @param exceptionSupplier The supplier which will return the exception to* be thrown* @return the present value* @throws X if there is no value present* @throws NullPointerException if no value is present and* {@code exceptionSupplier} is null*/public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {if (value != null) {return value;} else {throw exceptionSupplier.get();}}/*** Indicates whether some other object is "equal to" this Optional. The* other object is considered equal if:* 指示某个其他对象是否“等于”此可选对象。如果出现以下情况,则另一个对象被视为相等:* <ul>* <li>it is also an {@code Optional} and;* 它也是一个Optional* <li>both instances have no value present or;* 两个实例都不存在值或* <li>the present values are "equal to" each other via {@code equals()}.* 当前值通过 equals() 彼此“相等”* </ul>** @param obj an object to be tested for equality*            一个要测试相等的对象* @return {code true} if the other object is "equal to" this object* otherwise {@code false}** <ul> @param obj  @return {code true} 如果另一个对象“等于”这个对象,否则 {@code false}*/@Overridepublic boolean equals(Object obj) {if (this == obj) {return true;}if (!(obj instanceof Optional)) {return false;}Optional<?> other = (Optional<?>) obj;return Objects.equals(value, other.value);}/*** Returns the hash code value of the present value, if any, or 0 (zero) if* no value is present.* 返回当前值的哈希代码值(如果有)或 0(零)(如果不存在任何值)** @return hash code value of the present value or 0 if no value is present*/@Overridepublic int hashCode() {return Objects.hashCode(value);}/*** Returns a non-empty string representation of this Optional suitable for* debugging. The exact presentation format is unspecified and may vary* between implementations and versions.* 返回此 Optional 适合调试的非空字符串表示形式。* 确切的演示格式未指定,可能因实现和版本而异。** @implSpec If a value is present the result must include its string* representation in the result. Empty and present Optionals must be* unambiguously differentiable.* 如果存在值,则结果必须在结果中包含其字符串表示形式。空和存在值的Optionals 必须明确可区分。** @return the string representation of this instance*/@Overridepublic String toString() {return value != null? String.format("Optional[%s]", value): "Optional.empty";}
}

相关文章:

java.util.Optional

原文链接 文章目录 1、Optional作用2、常用API构造相关get / orElse / orElseGet / orElseThrowisPresent / ifPresentfiltermap / flatMap 3、源码翻译 1、Optional作用 类位于&#xff1a;java.util.Optional臭名昭著的空指针异常是导致Java应用程序失败的最常见原因&#…...

微服务--Seata(分布式事务)

TCC模式在代码中实现&#xff1a;侵入性强&#xff0c;并且的自己实现事务控制逻辑 Try&#xff0c;Confirm() cancel() 第三方开源框架&#xff1a;BeyeTCC\TCC-transaction\Himly 异步实现&#xff1a;MQ可靠消息最终一致性 GlobalTransacational---AT模式...

发光太阳聚光器的蒙特卡洛光线追踪研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...

(涨知识)-圣诞灯串类产品出口都需要做哪些认证?

1. 首先我们讲讲欧盟&#xff0c; 欧盟一向都是合规要求特别多的一个国家&#xff0c;所以向欧盟出口灯串等电子产品&#xff0c;一定要长个心眼。废话不多说&#xff0c;进入正题吧&#xff01; ①欧盟产品安全&#xff1a;欧代CE(电磁指令EMC低压指令LVD)DOC 产品安全必备三件…...

ROS地图/像素坐标描点调试【Python源码实现】

文章目录 ROS python 地图描点调试工具1. Rviz描点1.1 需求描述1.2 visualization Marker1.3 工程实践 2. 静态地图图片描点2.1 需求描述2.2 工程实践 ROS python 地图描点调试工具 1. Rviz描点 1.1 需求描述 在ROS开发中&#xff0c;有时会加载图片文件转为地图载入move_ba…...

2023年7月京东笔记本电脑行业品牌销售排行榜(京东数据平台)

随着智能手机、平板电脑等移动互联设备的普及&#xff0c;人们对于个人电脑的依赖减轻&#xff0c;加之电脑的更换率较低&#xff0c;因此当前PC端消费市场整体出现疲态&#xff0c;笔记本电脑的出货量不断下降&#xff0c;今年7月份也同样呈现这一趋势。 根据鲸参谋电商数据分…...

用户忠诚度:小程序积分商城的用户保持方法

随着移动互联网的蓬勃发展&#xff0c;小程序积分商城已经成为了许多企业私域营销的热门选择。这个商城不仅可以吸引用户参与&#xff0c;还可以提高用户的忠诚度&#xff0c;进一步加深用户与品牌的互动关系。然而&#xff0c;要实现用户的忠诚度&#xff0c;需要一系列的策略…...

[前端] 使用lerna version更新版本号

lerna version 是一个用于管理 monorepo&#xff08;多包存储库&#xff09;的工具&#xff0c;它可以帮助您在多个相关包之间协调版本号的更新和发布。以下是使用 lerna version 更新版本号的一般步骤&#xff1a; 安装 Lerna&#xff1a; 首先&#xff0c;您需要在您的项目中…...

winform嵌入浏览器 webView2

1、项目引用nuget 2、winform窗体中初始化 var webView new WebView2();webView.Source new Uri(url);webView.Dock DockStyle.Fill;//接收js调用c#函数的消息webView.WebMessageReceived CoreWebView2_WebMessageReceivedAsync; this.panel1.Controls.Add(…...

stm32---用外部中断实现红外接收器

一、红外遥控的原理 红外遥控是一种无线、非接触控制技术&#xff0c;具有抗干扰能力强&#xff0c;信息传 输可靠&#xff0c;功耗低&#xff0c;成本低&#xff0c;易实现等显著优点&#xff0c;被诸多电子设备特别是 家用电器广泛采用&#xff0c;并越来越多的应用到计算机系…...

Filter过滤器及HttpServletRequest和HttpServletResponse

拦截器&#xff08;Interceptor&#xff09;和过滤器&#xff08;Filter&#xff09;的执行顺序 tomcat->Filter->Interceptor->Controller 过滤器&#xff08;Filter&#xff09;概述&#xff1f; Filter过滤器是JavaWeb的三大组件之一&#xff0c;三大组件分别为&…...

02-打包代码与依赖

打包代码与依赖说明 在开发中&#xff0c;我们写的应用程序通常需要依赖第三方的库&#xff08;即程序中引入了既不在 org.apache.spark包&#xff0c;也不再语言运行时的库的依赖&#xff09;&#xff0c;我们就需要确保所有的依赖在Spark应用运行时都能被找到 对于Python而…...

Kotlin(五) 循环语句

目录 For循环 关键字 until step downTo Java中主要有两种循环语句&#xff1a;while循环和for循环。而Kotlin也提供了while循环和for循环&#xff0c;其中while循环不管是在语法还是使用技巧上都和Java中的while循环没有任何区别&#xff0c;因此我们就直接跳过不进行讲解…...

数字孪生产品:数字化时代的变革引擎

数字孪生技术&#xff0c;作为一项前沿的科技创新&#xff0c;正在不断改变我们的世界。它为各行各业的发展提供了无限的可能性&#xff0c;成为了当今数字化时代的一大亮点。数字孪生产品&#xff0c;作为数字孪生技术的具体应用&#xff0c;将在未来发挥越来越重要的作用。 数…...

对接西部数据Western Digital EDI 系统

近期我们为国内某知名电子产品企业提供EDI解决方案&#xff0c;采用知行之桥 EDI 系统作为核心组件&#xff0c;成功与西部数据Western Digital&#xff08;简称西数&#xff09;建立EDI连接&#xff0c;实现数据安全且自动化传输。 EDI实施需求 EDI连接 传输协议&#xff1a;A…...

ClickHouse进阶(十):Clickhouse数据查询-4

进入正文前&#xff0c;感谢宝子们订阅专题、点赞、评论、收藏&#xff01;关注IT贫道&#xff0c;获取高质量博客内容&#xff01; &#x1f3e1;个人主页&#xff1a;含各种IT体系技术,IT贫道_Apache Doris,大数据OLAP体系技术栈,Kerberos安全认证-CSDN博客 &#x1f4cc;订阅…...

FPGA原理与结构——FIFO IP核的使用与测试

一、前言 本文介绍FIFO Generator v13.2 IP核的具体使用与例化&#xff0c;在学习一个IP核的使用之前&#xff0c;首先需要对于IP核的具体参数和原理有一个基本的了解&#xff0c;具体可以参考&#xff1a; FPGA原理与结构——FIFO IP核原理学习https://blog.csdn.net/apple_5…...

ABB CMA120 3DDE300400面板

人机界面&#xff1a;ABB CMA120 3DDE300400 面板通常具有用户友好的人机界面&#xff0c;可用于监视和控制连接设备和系统的操作。 图形显示&#xff1a;该面板通常具有高分辨率的液晶显示屏&#xff0c;用于显示图形界面和实时数据&#xff0c;以便操作员更容易理解和管理工…...

【代码随想录day25】动态规划:01背包理论基础

题目 有n件物品和一个最多能背重量为w 的背包。第i件物品的重量是weight[i]&#xff0c;得到的价值是value[i] 。每件物品只能用一次&#xff0c;求解将哪些物品装入背包里物品价值总和最大。 代码 dp[i][j]: 表示从0~i个物品中选物品放到容量为j的背包中所能获得的最大价值 …...

Python Opencv实践 - 轮廓检测

import cv2 as cv import numpy as np import matplotlib.pyplot as pltimg cv.imread("../SampleImages/map.jpg") print(img.shape) plt.imshow(img[:,:,::-1])#Canny边缘检测 edges cv.Canny(img, 127, 255, 0) plt.imshow(edges, cmapplt.cm.gray)#查找轮廓 #c…...

【Linux】shell脚本忽略错误继续执行

在 shell 脚本中&#xff0c;可以使用 set -e 命令来设置脚本在遇到错误时退出执行。如果你希望脚本忽略错误并继续执行&#xff0c;可以在脚本开头添加 set e 命令来取消该设置。 举例1 #!/bin/bash# 取消 set -e 的设置 set e# 执行命令&#xff0c;并忽略错误 rm somefile…...

【Java学习笔记】Arrays类

Arrays 类 1. 导入包&#xff1a;import java.util.Arrays 2. 常用方法一览表 方法描述Arrays.toString()返回数组的字符串形式Arrays.sort()排序&#xff08;自然排序和定制排序&#xff09;Arrays.binarySearch()通过二分搜索法进行查找&#xff08;前提&#xff1a;数组是…...

在HarmonyOS ArkTS ArkUI-X 5.0及以上版本中,手势开发全攻略:

在 HarmonyOS 应用开发中&#xff0c;手势交互是连接用户与设备的核心纽带。ArkTS 框架提供了丰富的手势处理能力&#xff0c;既支持点击、长按、拖拽等基础单一手势的精细控制&#xff0c;也能通过多种绑定策略解决父子组件的手势竞争问题。本文将结合官方开发文档&#xff0c…...

Vue3 + Element Plus + TypeScript中el-transfer穿梭框组件使用详解及示例

使用详解 Element Plus 的 el-transfer 组件是一个强大的穿梭框组件&#xff0c;常用于在两个集合之间进行数据转移&#xff0c;如权限分配、数据选择等场景。下面我将详细介绍其用法并提供一个完整示例。 核心特性与用法 基本属性 v-model&#xff1a;绑定右侧列表的值&…...

大语言模型如何处理长文本?常用文本分割技术详解

为什么需要文本分割? 引言:为什么需要文本分割?一、基础文本分割方法1. 按段落分割(Paragraph Splitting)2. 按句子分割(Sentence Splitting)二、高级文本分割策略3. 重叠分割(Sliding Window)4. 递归分割(Recursive Splitting)三、生产级工具推荐5. 使用LangChain的…...

C++中string流知识详解和示例

一、概览与类体系 C 提供三种基于内存字符串的流&#xff0c;定义在 <sstream> 中&#xff1a; std::istringstream&#xff1a;输入流&#xff0c;从已有字符串中读取并解析。std::ostringstream&#xff1a;输出流&#xff0c;向内部缓冲区写入内容&#xff0c;最终取…...

关于 WASM:1. WASM 基础原理

一、WASM 简介 1.1 WebAssembly 是什么&#xff1f; WebAssembly&#xff08;WASM&#xff09; 是一种能在现代浏览器中高效运行的二进制指令格式&#xff0c;它不是传统的编程语言&#xff0c;而是一种 低级字节码格式&#xff0c;可由高级语言&#xff08;如 C、C、Rust&am…...

CRMEB 框架中 PHP 上传扩展开发:涵盖本地上传及阿里云 OSS、腾讯云 COS、七牛云

目前已有本地上传、阿里云OSS上传、腾讯云COS上传、七牛云上传扩展 扩展入口文件 文件目录 crmeb\services\upload\Upload.php namespace crmeb\services\upload;use crmeb\basic\BaseManager; use think\facade\Config;/*** Class Upload* package crmeb\services\upload* …...

Maven 概述、安装、配置、仓库、私服详解

目录 1、Maven 概述 1.1 Maven 的定义 1.2 Maven 解决的问题 1.3 Maven 的核心特性与优势 2、Maven 安装 2.1 下载 Maven 2.2 安装配置 Maven 2.3 测试安装 2.4 修改 Maven 本地仓库的默认路径 3、Maven 配置 3.1 配置本地仓库 3.2 配置 JDK 3.3 IDEA 配置本地 Ma…...

Git 3天2K星标:Datawhale 的 Happy-LLM 项目介绍(附教程)

引言 在人工智能飞速发展的今天&#xff0c;大语言模型&#xff08;Large Language Models, LLMs&#xff09;已成为技术领域的焦点。从智能写作到代码生成&#xff0c;LLM 的应用场景不断扩展&#xff0c;深刻改变了我们的工作和生活方式。然而&#xff0c;理解这些模型的内部…...