找到 34423 篇文章 相关编程

Java 中 CopyOnWriteArrayList 方法的 isEmpty() 方法

Arjun Thakur
更新于 2019-07-30 22:30:25

84 次浏览

要检查列表是否为空,请使用 isEmpty() 方法。如果列表为空,则返回 TRUE,否则返回 FALSE。语法如下boolean isEmpty()要使用 CopyOnWriteArrayList 类,您需要导入以下包import java.util.concurrent.CopyOnWriteArrayList;以下是 Java 中实现 CopyOnWriteArrayList 类 isEmpty() 方法的示例示例 实时演示import java.util.concurrent.CopyOnWriteArrayList; public class Demo {    public static void main(String[] args) {       CopyOnWriteArrayList arrList = new CopyOnWriteArrayList();       arrList.add(30);       arrList.add(40);       arrList.add(60);       arrList.add(70);       arrList.add(90);       ... 阅读更多

Java 中的 MonthDay isAfter() 方法

Krantik Chavan
更新于 2019-07-30 22:30:25

82 次浏览

可以使用 Java 中 MonthDay 类的 isAfter() 方法检查特定 MonthDay 是否在时间线上在另一个 MonthDay 之后。此方法需要一个参数,即要比较的 MonthDay 对象。如果 MonthDay 对象在另一个 MonthDay 对象之后,则返回 true,否则返回 false。以下给出了演示此方法的程序示例 实时演示import java.time.*; public class Main {    public static void main(String[] args) {       MonthDay md1 = MonthDay.parse("--02-25");       MonthDay md2 = MonthDay.parse("--02-21");       System.out.println("The MonthDay md1 is: " ... 阅读更多

Java 中的 MonthDay isBefore() 方法

Krantik Chavan
更新于 2019-07-30 22:30:25

83 次浏览

可以使用 Java 中 MonthDay 类的 isBefore() 方法检查特定 MonthDay 是否在时间线上在另一个 MonthDay 之前。此方法需要一个参数,即要比较的 MonthDay 对象。如果 MonthDay 对象在另一个 MonthDay 对象之前,则返回 true,否则返回 false。以下给出了演示此方法的程序示例 实时演示import java.time.*; public class Main {    public static void main(String[] args) {       MonthDay md1 = MonthDay.parse("--02-15");       MonthDay md2 = MonthDay.parse("--02-21");       System.out.println("The MonthDay md1 is: " ... 阅读更多

Java 中的 MonthDay range() 方法

Daniol Thomas
更新于 2019-07-30 22:30:25

79 次浏览

可以使用 Java 中 MonthDay 类的 range() 方法获取 ChronoField 的值范围。此方法需要一个参数,即需要其值范围的 ChronoField,它返回值范围。以下给出了演示此方法的程序示例 实时演示import java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Main {    public static void main(String[] args) {       MonthDay md = MonthDay.parse("--02-21");       System.out.println("The MonthDay is: " + md);       ValueRange range = md.range(ChronoField.DAY_OF_MONTH);       System.out.println("The range of DAY_OF_MONTH is: ... 阅读更多

Java 中 CopyOnWriteArrayList 的 listIterator() 方法,从指定位置开始

Ankith Reddy
更新于 2019-07-30 22:30:25

109 次浏览

CopyOnWriteArrayList 类的 listIterator() 方法返回此列表中元素上的列表迭代器,从列表中指定位置开始。语法如下public ListIterator listIterator(int index)这里,index 是要从列表迭代器返回的第一个元素的索引。要使用 CopyOnWriteArrayList 类,您需要导入以下包import java.util.concurrent.CopyOnWriteArrayList;以下是 Java 中实现 CopyOnWriteArrayList 类 listIterator() 方法的示例。我们已将索引设置为 3,因此列表将从索引 3 开始迭代示例 实时演示import java.util.Iterator; import java.util.ListIterator; import java.util.concurrent.CopyOnWriteArrayList; public class Demo {    public static void main(String[] ... 阅读更多

Java 中的 MonthDay hashCode() 方法

Daniol Thomas
更新于 2019-07-30 22:30:25

94 次浏览

可以使用 Java 中 MonthDay 类的 hashCode() 方法获取 MonthDay 的哈希码值。此方法不需要参数,它返回 MonthDay 的哈希码值。以下给出了演示此方法的程序示例 实时演示import java.time.*; public class Demo {    public static void main(String[] args) {         MonthDay md = MonthDay.parse("--02-21");       System.out.println("The MonthDay is: " + md);       System.out.println("The hash code is: " + md.hashCode());    } }输出The MonthDay is: --02-21 The hash code is: 149现在让我们了解上述程序。首先 ... 阅读更多

Java 中的 LongStream filter() 方法

George John
更新于 2019-07-30 22:30:25

133 次浏览

Java 中 LongStream 类的 filter() 方法返回一个流,该流包含此流中与给定谓词匹配的元素。语法如下LongStream filter(LongPredicate predicate)这里,参数 predicate 是一个无状态谓词,应用于每个元素以确定是否应将其包含在内。LongPredicate 表示一个具有一个长值参数的谓词(布尔值函数)要在 Java 中使用 LongStream 类,请导入以下包import java.util.stream.LongStream;以下是 Java 中实现 LongStream filter() 方法的示例示例 实时演示import java.util.*; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) { LongStream longStream = ... 阅读更多

Java 中的 LocalTime from() 方法

Daniol Thomas
更新于 2019-07-30 22:30:25

49 次浏览

可以使用 Java 中 LocalTime 类的 from() 方法从 Temporal 对象获取 LocalTime 对象的实例。此方法需要一个参数,即 Temporal 对象,它返回从 Temporal 对象获取的 LocalTime 对象。以下给出了演示此方法的程序:import java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt = LocalTime.from(ZonedDateTime.now());       System.out.println("The LocalTime is: " + lt);    } }上述程序的输出如下:The LocalTime is: 10:09:29.696现在让我们了解 ... 阅读更多

Java 中 AbstractList 类的 addAll() 方法

Chandu yadav
更新于 2019-07-30 22:30:25

117 次浏览

AbstractList 类的 addAll() 方法用于将指定集合中的所有元素插入到此列表的指定位置。语法如下boolean addAll(int index, Collection

Java 中的 LocalTime format() 方法

Daniol Thomas
更新于 2019-07-30 22:30:25

116 次浏览

可以使用 Java 中 LocalTime 类的 format() 方法使用指定的格式化程序格式化 LocalTime。此方法需要一个参数,即要格式化的 LocalTime 对象,它返回使用指定的格式化程序格式化的 LocalTime。以下给出了演示此方法的程序:示例 实时演示import java.util.*; import java.time.*; import java.time.format.DateTimeFormatter; public class Main {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("14:30:47");       System.out.println("The LocalTime is: " + lt);       DateTimeFormatter dtf = DateTimeFormatter.ISO_TIME;       System.out.println("The formatted LocalTime is: " + dtf.format(lt)); ... 阅读更多

广告

© . All rights reserved.