Java中的Arrays.fill复杂度 [英] Arrays.fill complexity in java
本文介绍了Java中的Arrays.fill复杂度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 java
中内部实现 Arrays.fill(char [] a,char val)
?
它的复杂性是什么?
推荐答案
如果您研究 java.util中可用的
类. fill(char [] a,char val)
的定义.数组
If you look into the definition of fill(char[] a, char val)
available in java.util.Arrays
Class.
就是这样
public static void fill(Object[] a, Object val) {
for (int i = 0, len = a.length; i < len; i++) //this loop will continues to the length of a.
a[i] = val;
}
因此,此方法的复杂度为 O(n)
.其中 n
是传递给参数的对象数组 Object [] a
的长度.
So, Complexity for this method would be O(n)
. where n
is the length of Object Array Object[] a
which you passed to the parameter.
这篇关于Java中的Arrays.fill复杂度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文