这个来源输出G'Day Mate.
这是怎么回事?
public static void main(String args[]) {
System.out.println("Hello World");
}
static {
try {
Field value = String.class.getDeclaredField("value");
value.setAccessible(true);
value.set("Hello World", value.get("G'Day Mate."));
} catch (Exception e) {
throw new AssertionError(e);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我们将主要功能更改"Hello World"
为new String("Hello World")
:
System.out.println(new String("Hello World"));
Run Code Online (Sandbox Code Playgroud)
它输出Hello world
.
实际上发生了什么?
我有一个没有在 pom 中定义依赖版本的 pom 工作正常,另一个没有依赖版本的 pom 不起作用。
一个有效的:
<project>
<parent>
<artifactId>artifact-parent</artifactId>
<groupId>group-parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-b</artifactId>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
这个不起作用:
<project>
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-b</artifactId>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
这两者的唯一不同似乎是:
<parent>
<artifactId>artifact-parent</artifactId>
<groupId>group-parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
第二个不起作用对我来说似乎很好,但我的问题是为什么第一个起作用?
引用自maven pom 参考:
这个三位一体代表了特定项目在时间上的坐标,将其划定为该项目的一个依赖项。
所以我的问题是第一个是如何工作的?
我的MySQL数据库有超过100万条记录,而且越来越多.我有一个值"援助",有时可以多次使用.我想算援助.
我试过了
SELECT COUNT ( DISTINCT (value) ) AS somevalue
FROM table
Run Code Online (Sandbox Code Playgroud)
哪个有效,但现在有这么多的值,它需要比max_exec_time更长的时间.我也尝试过与GROUP BY相同而没有成功.
有没有办法快速运行此查询?或者还有其他解决方案吗?