我注意到像这样初始化2D数组
情况1 :-
int ar [] [] = new int [10000001][10] ;
Run Code Online (Sandbox Code Playgroud)
花费更多的时间而不是像这样初始化它
案例2: -
int ar[] [] = new int [10] [10000001] ;
Run Code Online (Sandbox Code Playgroud)
在案例1中,它的时间大约是4000毫秒,但在案例2中它不超过100毫秒,为什么会有这么大的差距?
我正在尝试使用 Flatlist 实现自定义拉动刷新指示器,有时我需要列表在负位置滚动以在顶部显示指示器,但 scrollToOffset 将我滚动到顶部而不是 y = 0
handleRelease() {
if (this.state.readyToRefresh) {
this.flatList.scrollToOffset({ offset: -130 });
}
}
<FlatList
ref={(flatList: any) => {
this.flatList = flatList;
}}
data={this.props.data}
renderItem={renderRowItem}
onScroll={this.handleScroll}
onResponderRelease={this.handleRelease}
scrollEventThrottle={16}
/>
Run Code Online (Sandbox Code Playgroud)
非负值似乎工作正常
在 Java 11 中运行此代码时,我期待 ClassCastExpection,但它执行时没有问题,这种情况有解释吗?
List<?> list = List.of(new HashMap<>());
List<String> listOfStrings = (List<String>) list;
System.out.println("List size: " + listOfStrings.size());
Run Code Online (Sandbox Code Playgroud)