public class First {
public static void main(String[] args) {
System.out.println("Hello Java 11");
}
}
Run Code Online (Sandbox Code Playgroud)
我试图用intellij在Java 11中运行上面的程序.但低于错误.
Information:javac 11 was used to compile java sources
Information:Internal caches are corrupted or have outdated format, forcing project rebuild: Module 'eleven-lab' production: java.net.MalformedURLException: unknown protocol: jrt
Information:25/09/18, 6:58 PM - Compilation completed with 1 error and 0 warnings in 4s 516ms
Error:Internal error: (java.net.MalformedURLException) unknown protocol: jrt
java.net.MalformedURLException: unknown protocol: jrt
at java.net.URL.<init>(URL.java:421)
at java.net.URL.<init>(URL.java:310)
at java.net.URL.<init>(URL.java:333)
at com.intellij.compiler.instrumentation.InstrumentationClassFinder.createJDKPlatformUrl(InstrumentationClassFinder.java:61)
at org.jetbrains.jps.incremental.instrumentation.ClassProcessingBuilder.createInstrumentationClassFinder(ClassProcessingBuilder.java:125)
at org.jetbrains.jps.incremental.instrumentation.ClassProcessingBuilder.build(ClassProcessingBuilder.java:93) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用在 js 中开发并在 GitHub 中可用的转译工具。此转译器能够将 javascript 代码转换为 java。
我想通过java代码调用该工具,以便我可以在java中读取js文件并使用在js中开发的transpiler处理它们。该工具使用“const”作为其代码的一部分。在使用 ScriptEngine 时,它给了我一个例外。请帮忙!!
示例代码:
public static void main(String[] args) {
ScriptEngineManager manager = null;
ScriptEngine engine = null;
File folder = null;
try {
manager = new ScriptEngineManager();
engine = manager.getEngineByName("nashorn");
String testConst1 = (String) "const pi = 3.14;";
String testPrint1 = (String) "function hello(name) {print ('Hello, ' + name +' = '+ pi);}";
engine.eval(testConst1);
engine.eval(testPrint1);
Invocable inv = (Invocable) engine;
inv.invokeFunction("hello", "pi");
// System.out.println(); //This one works.
} catch (Exception e) …Run Code Online (Sandbox Code Playgroud) 在 Java 8 中,我编写了一些示例代码。
String s1 = "Hello";
String s2 = "world";
String s3 = s1 + s2;
Run Code Online (Sandbox Code Playgroud)
反编译 .class 文件后,我发现了第三条语句
String s3 = s1 + s2;
Run Code Online (Sandbox Code Playgroud)
取而代之
String s3 = new StringBuilder(s1).append(s2).toString();
Run Code Online (Sandbox Code Playgroud)
这是否意味着不再需要使用显式 StringBuilder 进行优化而只需使用“+”运算符而不是?
我在 MySQL 中有下表。
city_data
+------+-----------+-------------+
| id | city_code | city_name |
+------+-----------+-------------+
| 4830 | BHR | Bharatpur |
| 4831 | KEP | Nepalgunj |
| 4833 | OHS | Sohar |
| 4834 | NULL | Shirdi |
+------+-----------+-------------+
Run Code Online (Sandbox Code Playgroud)
和下面的查询。
从 city_data 中选择 id、city_code、city_name,其中 city_code != 'BHR';
我本来期待 3 排。
| 4831 | KEP | Nepalgunj |
| 4833 | OHS | Sohar |
| 4834 | NULL | Shirdi |
+------+-----------+-------------+
Run Code Online (Sandbox Code Playgroud)
但只得到 2 行。
| 4831 …Run Code Online (Sandbox Code Playgroud)