
提示Syntax error怎样解决?
packagesrc;importsrc.Year;publicclassDaysCount{privateintnian;privateintyue;publicint...
package src;
import src.Year;
public class DaysCount {
private int nian;
private int yue;
public int getNian() {
return nian;
}
public void setNian(int nian) {
this.nian = nian;
}
public int getYue() {
return yue;
}
public void setYue (int yue) {
this.yue = yue;
}
public DaysCount (int nian, int yue)
{
super ();
this.nian = nian;
this.yue = yue;
}
public int jstshu () {
int tianshu = 0;
switch (yue)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
tianshu = 31;
break;
case 4:
case 6:
case 9:
case 11:
tianshu=30;
break;
case 2:
Year y = new Year(nian) ;
if (y.isLeap ()==true)
tianshu= 29;
else
{
tianshu= 28;
break;
return tianshu;
}
} 展开
import src.Year;
public class DaysCount {
private int nian;
private int yue;
public int getNian() {
return nian;
}
public void setNian(int nian) {
this.nian = nian;
}
public int getYue() {
return yue;
}
public void setYue (int yue) {
this.yue = yue;
}
public DaysCount (int nian, int yue)
{
super ();
this.nian = nian;
this.yue = yue;
}
public int jstshu () {
int tianshu = 0;
switch (yue)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
tianshu = 31;
break;
case 4:
case 6:
case 9:
case 11:
tianshu=30;
break;
case 2:
Year y = new Year(nian) ;
if (y.isLeap ()==true)
tianshu= 29;
else
{
tianshu= 28;
break;
return tianshu;
}
} 展开
展开全部
应该是英文字符打成中文字符了,改过来就可以了。
解决办法:
发现提示错误:SyntaxError:illegal character.
2.SyntaxError:illegal character翻译的结果是:非法字符。这里需要说明的是,如果你在日常编写代码的过程中,大多数语言如果给你报这个错,多半就是在程序中使用了中文字符,照成了系统不能识别给你报错。这种错误大多数就是许多人写的时候不注意,把英文的逗号“,”写成了中文的逗号”,”;或者就是分号写成了中文的。
3.再返回看错误提示,还有一个小箭头指向一个字符“,”,仔细一看,这里不小心把逗号写成了中文的,改成英文字符就可以了。
4.改成功后刷新一下,问题就解决了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询