简体   繁体   English

Java - 在编译期间找不到类Checksum

[英]Java - cannot find class Checksum during compilation

My program failed to compile when I tried to run this statement: 当我尝试运行此语句时,我的程序无法编译:

Checksum checksum = new CRC32();

Error: cannot find symbol 错误:找不到符号

symbol: class Checksum 符号:类Checksum

I have done the following at the beginning of the program. 我在课程开始时做了以下工作。

import java.util.*;

What went wrong? 什么地方出了错?

make sure you imported the following 确保您导入以下内容

import java.util.zip.CRC32;
import java.util.zip.Checksum;

You have to import java.util.zip.* to use Checksum. 您必须导入java.util.zip。*才能使用Checksum。 Because its in the inner package and JVM don't go into deeper package 因为它在内部包和JVM中不会进入更深层的包

Importing java.util.* doesn't import nested packages like java.util.zip , which Checksum and CRC32 are part of. 导入java.util.*不会导入像java.util.zip这样的嵌套包, ChecksumCRC32是其中的一部分。 Use 采用

import java.util.zip.*;

And you shouldn't get any compile errors. 你不应该得到任何编译错误。 Also, you should use an IDE like Eclipse, as they automatically manage things like this for you. 此外,您应该使用像Eclipse这样的IDE,因为它们会自动为您管理这样的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM