我是C#新手,我遇到了一个问题.处理三元运算符(? :)时,C#和Java之间存在差异.
在以下代码段中,为什么第4行不起作用?编译器显示错误消息there is no implicit conversion between 'int' and 'string'.第5行不起作用.两者List都是对象,不是吗?
int two = 2;
double six = 6.0;
Write(two > six ? two : six); //param: double
Write(two > six ? two : "6"); //param: not object
Write(two > six ? new List<int>() : new List<string>()); //param: not object
Run Code Online (Sandbox Code Playgroud)
但是,相同的代码适用于Java:
int two = 2;
double six = 6.0;
System.out.println(two > six ? two : six); //param: double
System.out.println(two > six ? two : …Run Code Online (Sandbox Code Playgroud) 用我原来的问题FileNotFoundException,并IllegalStateException因此它们被包含在了答案。我让他们改变了自己的超类IOException,并RuntimeException分别进行简单。
编译(不使用三进制,1个选中,1个未选中):
private void test() throws IOException { // throws is required
if (new Random().nextInt(2)==0) throw new IOException();
throw new RuntimeException();
}
Run Code Online (Sandbox Code Playgroud)
这也会编译(使用三元,2个未经检查的异常):
private void test3() { // throws not required
throw new Random().nextInt(2)==0 ? new UncheckedIOException(null) : new RuntimeException();
}
Run Code Online (Sandbox Code Playgroud)
但是为什么不编译(使用三进制,1个选中的,1个未选中的)?
private void test2() throws IOException {
throw new Random().nextInt(2)==0 ? new IOException() : new RuntimeException();
}
Run Code Online (Sandbox Code Playgroud)
从Eclipse:
未处理的异常类型Exception
2个快速修复可用:
J!添加引发声明
J!环绕尝试/捕捉
这样编译:
private void test4() { // …Run Code Online (Sandbox Code Playgroud) 这是关于 Spring Cloud Config Server业余爱好项目(带有@EnableConfigServer)。
昨天,可以开始申请了。
\n今天,由于 Git 通信错误,应用程序无法启动。
\n从GitHub 的官方博客文章中提到,从 2022 年 3 月 15 日开始,不再支持 SHA-1。这解释了我这两天得到的结果。
\n\n\n2022 年 3 月 15 日
\n改变成为永久性的。
\n我们\xe2\x80\x99将永久停止接受 DSA 密钥。在上述截止点之后上传的 RSA 密钥仅适用于 SHA-2 签名(但同样,在此日期之前上传的 RSA 密钥将继续适用于 SHA-1)。已弃用的 MAC、密码和未加密的 Git 协议将被永久禁用。
\n
即使我没有删除现有的 SSH 密钥,今天仍然无法启动。但无论如何,现在存储库设置的“部署密钥”部分下的唯一密钥是 2022 年 3 月 15 日截止日期之后添加的 SSH 密钥。
\n依赖管理:
\n| 依赖性 | 版本 |
|---|---|
| spring-cloud-依赖项 | 霍克斯顿.SR12 |
依赖关系: …