Java: I am receiving this error message when I compile on Java: The type java.lang.CharSequence cannot be resolved. It i

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Java: I am receiving this error message when I compile on Java: The type java.lang.CharSequence cannot be resolved. It i

Post by answerhappygod »

Java:
I am receiving this error message when I compile on Java: The
type java.lang.CharSequence cannot be resolved. It is indirectly
referenced from required .class files
Here is the code:
public class EncryptorOne implements Encryptor {
int key;
public EncryptorOne(int key) {
this.key = key;
}
public String encrypt(String plainText) {
StringBuffer
encrypted = new StringBuffer();
for (char letter :
plainText.toCharArray()) {
if (Character.isLetter(letter)) {
int shiftedLetter = letter + key;
char shiftedCharacter = (char) shiftedLetter;
if (shiftedLetter > 'z') {
shiftedLetter = 'a' + shiftedLetter - 'z'-1;
shiftedCharacter = (char) shiftedLetter;
}
encrypted.append(shiftedCharacter); //this is the error
line
} else {
encrypted.append(letter);
}
}
return
encrypted.toString();
}
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply