标题:照书上打的,不能运行
取消只看楼主
ehszt
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:40
帖 子:1728
专家分:3216
注 册:2015-12-2
结帖率:100%
已结贴  问题点数:20 回复次数:4 
照书上打的,不能运行
import java.util.Date;
public class hello

{
      
       public static void main(String[] args)

       {
          Date date=new Date();
          String hour=String.format("%tH",date);
          String minute=String.format("%tM", date);
          String second=String.format("%tS",date);
          System.out.println("现在是:"+hour+"时"+minute+"分"+second+"秒");

       }

}
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
    The method format(String, Object[]) in the type String is not applicable for the arguments (String, Date)
    The method format(String, Object[]) in the type String is not applicable for the arguments (String, Date)
    The method format(String, Object[]) in the type String is not applicable for the arguments (String, Date)

    at hello.main(hello.java:10)
搜索更多相关主题的帖子: Date String format The type 
2018-02-18 10:45
ehszt
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:40
帖 子:1728
专家分:3216
注 册:2015-12-2
得分:0 
以下是引用疯狂的小a在2018-2-18 11:00:41的发言:

类名首字母要大写

好像不是这个问题。
2018-02-18 15:34
ehszt
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:40
帖 子:1728
专家分:3216
注 册:2015-12-2
得分:0 
import java.util.Date;
这一句有个叉叉。
2018-02-18 21:02
ehszt
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:40
帖 子:1728
专家分:3216
注 册:2015-12-2
得分:0 
以下是引用疯狂的小a在2018-2-18 22:17:24的发言:

依赖jdk的环境,没有环境,就引不进来包

在cmd下输入javac和java是有输出的,表明有jdk环境。
2018-02-20 18:42
ehszt
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:40
帖 子:1728
专家分:3216
注 册:2015-12-2
得分:0 
已解决就是那个叉叉的问题,点下那个叉叉选第二项就好了。
谢谢楼上各位。
2018-02-21 20:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-484777-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.003996 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved