java提示The left-hand side of an assignment must be a variable怎么解决??
importjava.util.*;publicclassCalendarDemo{publicstaticvoidmain(String[]args){Calendar...
import java.util.*;
public class CalendarDemo {
public static void main(String[] args)
{
Calendar c1 = Calendar.getInstance();
System.out.println(c1.get(c1.YEAR)+"年"+(c1.get(c1.MONTH))+1)
+"月"+c1.get(c1.DAY_OF_MONTH)+"日"+c1.get(c1.HOUR)+
":"+c1.get(c1.MINUTE)+":"+c1.get(c1.SECOND));
c1.add(c1.DAY_OF_YEAR,230);
System.out.println(c1.get(c1.YEAR)+"年"+(c1.get(c1.MONTH))+1)+"月"+c1.get(c1.DAY_OF_MONTH)+"日"+c1.get(c1.HOUR)+":"+c1.get(c1.MINUTE)+":"+c1.get(c1.SECOND));
}
在这里System.out.println(c1.get(c1.YEAR)+"年"+(c1.get(c1.MONTH))+1)
+提示The left-hand side of an assignment must be a variable错误,还有后面的括号也提示了Syntax error on token ")", delete this token错误,这是什么原因啊? 展开
public class CalendarDemo {
public static void main(String[] args)
{
Calendar c1 = Calendar.getInstance();
System.out.println(c1.get(c1.YEAR)+"年"+(c1.get(c1.MONTH))+1)
+"月"+c1.get(c1.DAY_OF_MONTH)+"日"+c1.get(c1.HOUR)+
":"+c1.get(c1.MINUTE)+":"+c1.get(c1.SECOND));
c1.add(c1.DAY_OF_YEAR,230);
System.out.println(c1.get(c1.YEAR)+"年"+(c1.get(c1.MONTH))+1)+"月"+c1.get(c1.DAY_OF_MONTH)+"日"+c1.get(c1.HOUR)+":"+c1.get(c1.MINUTE)+":"+c1.get(c1.SECOND));
}
在这里System.out.println(c1.get(c1.YEAR)+"年"+(c1.get(c1.MONTH))+1)
+提示The left-hand side of an assignment must be a variable错误,还有后面的括号也提示了Syntax error on token ")", delete this token错误,这是什么原因啊? 展开
2个回答
展开全部
import java.util.Calendar;
public class CalendarDemo {
public static void main(String[] args) {
Calendar c1 = Calendar.getInstance();
System.out.println(c1.get(c1.YEAR) + "年" + (c1.get(c1.MONTH) + 1) + "月" + c1.get(c1.DAY_OF_MONTH) + "日"
+ c1.get(c1.HOUR) + ":" + c1.get(c1.MINUTE) + ":" + c1.get(c1.SECOND));
c1.add(c1.DAY_OF_YEAR, 230);
System.out.println(c1.get(c1.YEAR) + "年" + (c1.get(c1.MONTH) + 1) + "月" + c1.get(c1.DAY_OF_MONTH) + "日"
+ c1.get(c1.HOUR) + ":" + c1.get(c1.MINUTE) + ":" + c1.get(c1.SECOND));
}
}
看看和你的一样吗?貌似没错啊。。。在我这里可以运行。。。
你这里多了个括号哥们。。。
追问
谢谢,太大意了,答案采纳了顺便问下遇到这个问题怎解The method showpop(Stack) is undefined for the type StackDemo
追答
方法showpop(Stack)没有被定义。。。应该是没有这个方法吧。。。你确定StackDemo中有这个方法?有相同的函数名但参数不一样是不一样的函数。。。
展开全部
括号不匹配,必须在最后一行加上一个大括号。
更多追问追答
追问
不好意思没粘贴出来,最后一行是有大括号的,错误的提示是在c1.get(c1.SECOND));
后面的括号这
追答
System.out.println(c1.get(c1.YEAR)+"年"+(c1.get(c1.MONTH))+1)应该改成System.out.println(c1.get(c1.YEAR)+"年"+(c1.get(c1.MONTH)+1)。下面的输出也是一样,括号不匹配
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询