Здравствуйте, моя сеть мастеров программного обеспечения.У меня есть вопросы относительно того, почему я не могу заставить свой класс компилироваться.Я получаю ошибку: не могу найти символ.Все эти классы находятся в одном блок-пакете.Я пробовал все варианты оператора импорта, но не могу удалить эту ошибку.Структура каталогов: blocklaw -> src -> all_classes_here.Я также попытался изменить объявление пакета blocklaw.src, но ничего не помогло.Я поделюсь своим кодом здесь,
package blocklaw;
import java.security.MessageDigest;
/*
* returns a string value of the true fact
*/
public class TrueFact implements Hashable {
private String trueFact;
private String hashFact;
private String source;
private String hashSource;
private int bytesLength;
private String hashedBytesLength;
private String hashedHash;
public TrueFact(String trueFact, String source){
this.trueFact = trueFact;
this.source = new Source(source).getSource();
byte[] bytes = trueFact.getBytes("UTF-8");
this.bytesLength = bytes.length;
setHashCode();
}
public String getTrueFact(){
return this.trueFact;
}
public String getHashFact(){
return this.hashFact;
}
public String getSource(){
return this.source;
}
public int getbytesLength(){
return this.bytesLength;
}
public String getHashedBytesLength(){
return this.hashedBytesLength;
}
public void setHashCode(){
this.hashFact = hash(this.trueFact);
this.hashSource = hash(this.source);
this.hashedBytesLength = hash(String.valueOf(this.bytesLength));
this.hashedHash = hash(this.hashFact+this.hashSource+this.hashedBytesLength);
}
public String getHashSource(){
return this.hashSource;
}
public String hash(String input){
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
//Applies sha256 to our input,
byte[] hash = digest.digest(input.getBytes("UTF-8"));
StringBuffer hexString = new StringBuffer(); // This will contain hash as hexidecimal
for (int i = 0; i < hash.length; i++) {
String hex = Integer.toHexString(0xff & hash[i]);
if(hex.length() == 1) hexString.append('0');
hexString.append(hex);
}
return hexString.toString();
}
catch(Exception e) {
throw new RuntimeException(e);
}
}
}
Насколько я понимаю, все классы в одном и том же пакете не нужно явно импортировать.Почему тогда моя ошибка такова, что он не может найти символ?
Ниже приведен интерфейс для Hashable ...
package blocklaw;
public interface Hashable{
public String hash();
}