java中元素有序是什么意思_在Java中,自然顺序是什么意思?

我有一个问题出现在过去的论文中(我正在为考试进行修订),我遇到了这个自然顺序一词,它似乎是一个关键字,因为它在纸张上以粗体显示.我已经在网上查看了Natural Order,但是找不到像我的问题要求的任何与arraylist相关的东西.

请注意,我不需要帮助解决实际问题,我只想了解自然顺序的含义.

题:

Write a Java static method called atLeast which takes an ArrayList of objects which

have natural order, an object of the element type of the ArrayList, and an integer n. A

call to the method should return true if at least n elements of the ArrayList are greater

than the element type object according to natural order, otherwise it should return false.

解决方法:

这可能意味着列表中的对象实现了Comparable:

This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class’s natural ordering, and the class’s compareTo method is referred to as its natural comparison method.

该声明将如下所示:

static >

boolean atLeast(List list, T key, int n) {

...

}

标签:arraylist,java

来源: https://codeday.me/bug/20191028/1952013.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值