小编Dan*_*ári的帖子

Kotlin中List和Array类型之间的区别

ListArray类型有什么区别?
它似乎可以与它们进行相同的操作(循环,过滤器表达式等),行为或用法有什么不同吗?

val names1 = listOf("Joe","Ben","Thomas")
val names2 = arrayOf("Joe","Ben","Thomas")

for (name in names1)
    println(name)
for (name in names2)
    println(name)
Run Code Online (Sandbox Code Playgroud)

kotlin

139
推荐指数
3
解决办法
4万
查看次数

Eclipse的"Outline"窗口在IntelliJ中等效

我想从Eclipse切换到IntelliJ.但我想首先确保我最喜欢的工具存在于IntelliJ中.

IntelliJ是否与Eclipse的停靠大纲窗口等效?

Eclipse大纲窗口示例

eclipse intellij-13

43
推荐指数
2
解决办法
1万
查看次数

Vaadin Grid vs Table

Vaadin 7中的组件GridTable组件有什么区别?

我应该使用哪种,何时使用?

java datagrid vaadin vaadin7 vaadin-grid

19
推荐指数
2
解决办法
2万
查看次数

Python内核为第二轮PyQt5 GUI而死

  • 在Python 3.5.2中使用Spyder | Anaconda 4.2.0(64位)Windows软件包.qt:5.6.0
  • 首次运行时,GUI窗口按预期打开
  • 对于第二次运行,没有任何打开,并且接收内核死亡,重新启动日志消息.

gui1.py:

import sys from PyQt5.QtWidgets import QApplication, QWidget

app = QApplication(sys.argv)

w = QWidget()

w.resize(250,150) w.show()

#sys.exit(app.exec_()) 
app.exec_()
Run Code Online (Sandbox Code Playgroud)

IPhython日志:

runfile('F:/work/ws_python/TestProj1/gui1/gui1.py', wdir='F:/work/ws_python/TestProj1/gui1')

runfile('F:/work/ws_python/TestProj1/gui1/gui1.py', wdir='F:/work/ws_python/TestProj1/gui1')

Kernel died, restarting

Kernel died, restarting

Kernel died, restarting
Run Code Online (Sandbox Code Playgroud)

为什么内核为第二次运行而死,以及如何解决它?

(即使使用#sys.exit(app.exec_())作为最后一行,也要这样做.)

python ipython spyder anaconda pyqt5

9
推荐指数
1
解决办法
5104
查看次数

Guice 3.0-启动时出现ArrayIndexOutOfBoundsException吗?

为什么Guice 3.0针对错误的配置组件(例如,缺少@Inject)抛出此异常而不是格式化消息?

Exception in thread "main" com.google.inject.internal.util.$ComputationException: java.lang.ArrayIndexOutOfBoundsException: 16640
    at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553)
    at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419)
    at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
    at com.google.inject.internal.util.$StackTraceElements.forMember(StackTraceElements.java:53)
    at com.google.inject.internal.Errors.formatInjectionPoint(Errors.java:716)
    at com.google.inject.internal.Errors.formatSource(Errors.java:678)
    at com.google.inject.internal.Errors.format(Errors.java:555)
    at com.google.inject.ConfigurationException.getMessage(ConfigurationException.java:70)
    at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
    at java.lang.Throwable.toString(Throwable.java:480)
    at java.lang.String.valueOf(String.java:2982)
    at java.io.PrintStream.println(PrintStream.java:821)
    at java.lang.Throwable$WrappedPrintStream.println(Throwable.java:748)
    at java.lang.Throwable.printStackTrace(Throwable.java:655)
    at java.lang.Throwable.printStackTrace(Throwable.java:643)
    at java.lang.Throwable.printStackTrace(Throwable.java:634)
    at hu.daniel.hari.exercises.cleanarchitecture.payrollcasestudy.adapters.primary.ui.impl.swing._2.SwingUIMain2.<init>(SwingUIMain2.java:40)
    at hu.daniel.hari.exercises.cleanarchitecture.payrollcasestudy.adapters.primary.ui.impl.swing._2.SwingUIMain2.main(SwingUIMain2.java:17)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 16640
    at com.google.inject.internal.asm.$ClassReader.readClass(Unknown Source)
    at com.google.inject.internal.asm.$ClassReader.accept(Unknown Source)
    at com.google.inject.internal.asm.$ClassReader.accept(Unknown Source)
    at com.google.inject.internal.util.$LineNumbers.<init>(LineNumbers.java:62)
    at com.google.inject.internal.util.$StackTraceElements$1.apply(StackTraceElements.java:36)
    at com.google.inject.internal.util.$StackTraceElements$1.apply(StackTraceElements.java:33)
    at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549)
    ... 17 more
Run Code Online (Sandbox Code Playgroud)

我initating代码是:

Injector injector = Guice.createInjector(new SwingUIModule(useCaseFactory));
injector.getInstance(MainFrameUI.class).show();
Run Code Online (Sandbox Code Playgroud)

guice-3

5
推荐指数
2
解决办法
3798
查看次数

避免空值检查条件运算符样板的最佳实践

当无法使用null对象时,更换条件运算符null-checks样板的最佳做法是:

public String getEmployeeName() {
    return employee == null ? null : employee.getName();
}
Run Code Online (Sandbox Code Playgroud)

在Java 8或任何实用程序库中是否有类似下面的内容?

public String getEmployeeName() {
    return nullable(employee, employee -> employee.getName());
}

private <T, R> R nullable(T nullable, Function<T, R> doIfNotNull) {
    return nullable == null ? null : doIfNotNull.apply(nullable);
}
Run Code Online (Sandbox Code Playgroud)

java optional java-8

4
推荐指数
1
解决办法
2189
查看次数

Java 8 List &lt;T&gt;到Map &lt;T,(index)&gt;

是否有一种方便的Java8流API方式从List<T> to Map<T, (index)>以下示例进行转换:

    List<Character> charList = "ABCDE".chars().mapToObj(e->(char)e).collect(Collectors.toList());

    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < charList.size(); i++) {
        map.put(charList.get(i), i);
    }
Run Code Online (Sandbox Code Playgroud)

映射= {A = 0,B = 1,C = 2,D = 3,E = 4}

java lambda java-8 java-stream

1
推荐指数
1
解决办法
1977
查看次数