![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java basic
文章平均质量分 61
静心观复
这个作者很懒,什么都没留下…
展开
-
futures.toArray(new CompletableFuture[0])
是一种常见的将List转换为数组的方式,特别是在需要将List传递给接受数组参数的方法时。让我们详细解释一下这段代码的具体含义和工作原理。原创 2024-07-05 13:50:10 · 521 阅读 · 0 评论 -
CompletableFuture用法
是 Java 8 引入的一个类,位于包中,它是 Java 对异步编程的一种支持。提供了丰富的 API,可以帮助你以非阻塞的方式异步执行任务,并且能够很方便地进行任务的组合和处理。原创 2024-07-03 10:43:31 · 932 阅读 · 0 评论 -
compute和computeIfAbsent的区别和用法
compute适用于需要根据键和值计算新值的情况。即使键不存在,也会调用计算函数。可以用于更新和删除键值对。适用于仅在键不存在时计算新值的情况。如果键已经存在,不会调用计算函数。只能用于添加新键值对,不会更新已存在的键值对。原创 2024-07-03 10:29:05 · 336 阅读 · 0 评论 -
java的flatMap和map的区别
flatMap是一个强大的操作,可以用来处理流中的嵌套结构,并将它们扁平化为一个更简单的流。这使得在处理复杂的数据结构时,我们可以更容易地应用各种流操作,如filtermap和collect。原创 2024-04-10 14:12:33 · 591 阅读 · 0 评论 -
TreeMap和HashMap的区别
选择HashMap还是TreeMap,取决于你的具体需求。如果需要快速的查找和插入,且不关心顺序,则HashMap是一个好的选择。如果你的应用需要有序遍历键或者按范围查询键,TreeMap将是更好的选择。在性能敏感的应用中,了解基础数据结构和操作的时间复杂度对于做出正确的选择至关重要。原创 2024-04-10 11:18:55 · 672 阅读 · 0 评论 -
自定义注解在Guice中的使用
Retention;Target;原创 2024-04-02 08:16:40 · 147 阅读 · 0 评论 -
java自定义注解
Java中的自定义注解是一种元数据形式,它允许在代码中添加信息,这些信息可以在编译时、类加载时或运行时被读取,并进行相应的处理。原创 2024-04-02 08:07:22 · 320 阅读 · 0 评论 -
Java Break,Continue and return
标题原创 2023-04-25 13:14:54 · 150 阅读 · 0 评论 -
Difference between Dynamic Proxy and Static Proxy
动态代理和静态代理的区别原创 2023-04-20 23:38:38 · 124 阅读 · 0 评论 -
Comparable 怎么判断是升序还是降序
这里的返回值是 this.age - o.age,所以如果 this.age > o.age,返回值会大于 0,排序在后,降序;如果 this.age < o.age,返回值会小于 0,排序在前,升序。现在 this.age > o.age 返回值会小于 0,排序在前,升序;this.age < o.age 返回值会大于 0,排序在后,降序。Comparable 接口的 compareTo 方法的返回值决定了排序的顺序。原创 2023-04-18 17:11:22 · 1088 阅读 · 0 评论 -
Memory Units And Java Primitive data types
Memory UnitsBit: The computer memory units start from bit.Byte: It is the fundamental unit to measure data. It contains 8 bits or is equal to 8 bits.Kilobyte: A kilobyte contains 1024 bytes.Megab...原创 2019-12-30 10:34:20 · 205 阅读 · 1 评论 -
Generics in Java
The Java Generics programming is introduced in J2SE 5 to deal with type-safe objects. It makes the code stable by detecting the bugs at compile time.一、Advantages of Generics:Code ReuseWe can write ...原创 2019-12-05 13:32:04 · 301 阅读 · 1 评论 -
Java object header
Have you ever wondered how java object looks like inside JVM ?First, remember that in jvm any object in memory consists of the object header and object variables (links and primitives).The header of...原创 2019-11-28 11:24:18 · 389 阅读 · 1 评论 -
Java Reflection Drawbacks And Use cases
The concept of reflection in software means the ability to inspect, analyze and modify other code at runtime.In Java, it is possible to inspect fields, classes, methods, annotations, interfaces, etc....原创 2019-11-20 17:59:28 · 92 阅读 · 0 评论 -
Java final keyword
In Java, we can use the final keyword to mark a -:Local variable(can not change),Instance variable(can not change),Method(cannot be redefined or overridden by a subclass),Class(cannot extend it)....转载 2019-11-20 13:31:41 · 140 阅读 · 0 评论 -
Static vs Instance Initialization Block
Static Initialization BlockInstance Initialization BlockTo define a static initialization block we use the keyword staticNo keyword is required to define an instance initialization block....转载 2019-11-20 10:46:59 · 132 阅读 · 0 评论 -
Static Initialization Blocks in Java
There are two variants of an initialization block in Java -Static initialization block.Instance Initialization block.Static initialization blockStatic initialization block is used to initialize cl...转载 2019-11-20 10:26:10 · 258 阅读 · 0 评论 -
Java Double Brace Initialization
1.OverviewIn this quick tutorial, we’ll show how double braces can be used for creating and initializing objects in a single Java expression.We’ll also look at why this technique can be considered a...转载 2019-11-19 17:21:03 · 237 阅读 · 0 评论 -
Instance Initialization Block (IIB) in Java
Instance Initialization Blocks or IIB are used to initialize instance variables. IIBs are executed before constructors. They run each time when object of the class is created.Initialization blocks a...转载 2019-11-19 17:09:40 · 190 阅读 · 0 评论 -
Spurious Wakeups in Java
What is Spurious Wakeups in Java threads?Object.wait() is supposed to block until either another thread invokes the Object.notify() or Object.notifyAll() method, or a specified amount of time has ela...原创 2019-09-17 11:22:00 · 218 阅读 · 0 评论 -
Java Comparable and Comparator interface
1 OverviewWe often need to compare two values in our Java programs. Comparing primitive values like int, char, float is very easy and can be done with comparison operators like <, >, == etc.Bu...原创 2019-09-04 13:41:48 · 222 阅读 · 0 评论