java - java.lang.Error 我在代码中遗漏了什么吗?
问题描述
如果有人知道我为什么会遇到此错误,这只是一个简单的查询,我将不胜感激。
问题是简单的 java if else if else 循环问题。
所以我试图使语法尽可能正确。下面的代码是我正在执行的代码。
public class ifelseloop {
public static void main(String[] args){
// int a = 20;
// int b = 20;
String city = "Delhi";
if (city == "madras") {
System.out.println("the city is not delhi its madras");
}else if(city == "chennai") {
System.out.println("the city is not delhi its chennai");
}else if(city == "bartar") {
System.out.println("the city is bartar");
}else {
System.out.println(city);
}
}
}
我得到的错误就是这个。
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at ifelseloop.main(ifelseloop.java:2)
解决方案
推荐阅读
- amazon-ec2 - 如何更改ubuntu显示名称?
- regex - windows powershell中的字符串拆分
- mysql - SQL Group 通过返回错误结果
- sql - 使用公式的攻击性能
- java - 在 H2 中切换同一事务中的两个唯一字段时违反唯一约束
- javascript - 函数问题,角度打字稿,匹配 2 个数组中的 id 值以从其中一个数组中获取索引
- javascript - ExpressJS 函数无法返回
- docker - 《如何用 api 连接 Docker 容器》
- python - 我可以删除正则表达式中除了这一件事之外的所有内容:“co-”。不知道如何处理破折号
- java - 我想用破折号对角线打印一个完整的 X 正方形