The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class

关于 The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class 报错的解决方法

又开始牙疼 …看不了什么东西 ,md,The
type java.lang.CharSequence cannot be resolved. It is indirectly referenced
from required .class,前几天用myeclipse10做项目遇到的一个问题,换了jdk6就好了,也没追究根源。正好趁现在解决一下

问题描述

在这里插入图片描述

项目报错,语法没问题,类的开头有一个红色叉号。删了这个类又从另一个类里出现,当时第一天写的时候没有报错,第二天打开继续写,直接在项目旁边出现了红色叉号,莫名其妙的跑出来个这玩意弄得我很头疼,然后就随便搜了一下,直接把jdk改成myeclipse自带的1.6就解决了。

问题出现的原因

Java 8 supports default methods in interfaces. And in JDK 8 a lot of old interfaces now have new default methods.For example, now in CharSequence we have chars and codePoints methods.If source level of your project is lowerthan 1.8, then compiler doesn‘t allow you to use default methods in interfaces. So it cannot compile classes that directly on indirectly depend on this interfaces.If I get your problem right, then you have two solutions. First solution is to rollback to JDK 7, then you will use old CharSequence interface without default methods. Second solution is
to set source level of your project to 1.8, then your compiler will not complain about default methods in interfaces.

大概就是说版本对不上,当时创建项目的时候我是用的JDK 1.6 ,第二天再打开时变成了自己设置的默认的JDK 1.8。

解决方法

解决方法有两种:

1.降低JDK;

2.升级IDE;

1.降低jdk

一开始使用的jdk 1.8,myeclipse 10好像用不了jdk 1.8

选择Window->Preferences。在Java下找到Installed JAEs,选择JDK 1.6 .

在这里插入图片描述

确认之后刷新一边,报错就没有了。
在这里插入图片描述

2.升级IDE

由于Myeclipse 10不支持jdk 1.8。直接换个IDE,比如eclipse、idea等等。。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java语言程序设计 第6章 字符串 Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第1页。 6.1.1 1 String类 2 3 主要内容 Java语言程序设计(第3版) 格式化输出 StringBuilder类 Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第2页。 6.1.1 String类 Java语言程序设计(第3版) Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第3页。 6.1.1 使用字符串字面值创建String对象。 String str = "Java is cool"; 使用String类的构造方法。 String str = new String("Java is cool"); 这两种方式有区别,后面说明。 创建字符串对象 Java语言程序设计(第3版) Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第4页。 6.1.1 字符串基本操作 Java语言程序设计(第3版) 字符串在内存的表示。设有下面声明: String str = new String("Java is cool"); 这个字符串共有12个字符,每个字符有一个下标,下标从0开始。 str.charAt(6)返回字母s。 Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第5页。 6.1.1 字符串基本操作 Java语言程序设计(第3版) 问题描述 编写一个方法判断字符串是否是回文串。 public static boolean isPalindrome(String s) 思路:取出字符串的第一个和最后一个比较,若不相同,程序结束,返回false。若相等,比较第二个字符和倒数第二字符,直到比较到字符串的中间字符为止,若都相等,则是回文,返回true。 Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第6页。 6.1.1 字符串查找 Java语言程序设计(第3版) int indexOf(int ch) int lastIndexOf(int ch) 找到返回下标值,找不到返回-1。 Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第7页。 6.1.1 字符串转换为数组 Java语言程序设计(第3版) char[] toCharArray() byte[] getBytes() Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第8页。 6.1.1 字符串比较 Java语言程序设计(第3版) 不能使用"=="号来比较字符串内容是否相等 比较内容是否相等: boolean equals(String str) boolean equalsIgnoreCase(String str) s1 s2 Hello Hello 字符串常量池 s1 s2 Hello Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第9页。 6.1.1 字符串比较 Java语言程序设计(第3版) 比较大小: int compareTo(String str) 小于,返回值小于0 等于,返回值等于0 大于,返回值大于0 判断前缀、后缀和包含 boolean startsWith(String prefix) boolean endsWith(String suffix) boolean contains(String str) String s1 = "ABC"; String s2 = "ABE"; System.out.println( s1.compareTo(s2); 输出-2 Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第10页。 6.1.1 字符串的拆分和组合 Java语言程序设计(第3版) String[] split(String regex) static String join(CharSequence delimiter, CharSequence... elements) boolean matches(String regex) Java语言程序设计(第3版)第06章-字符串全文共31页,当前为第11页。 6.1.1 String对象的不变性 Java语言程序设计(第3版) 一旦创建一个String对象,就不能对其内容进行改变。 s Hello,world s.replace('o','A'); HellA,wArld s = s.substring(0,6).concat("Java"); Hello,Java s s.toUpperCase(); HELLO,JAVA System.out.println(s); String s = "Hello,wo
Java String 类型 API 测试代码 1.String和char[]之间的转换 toCharArray(); 2.String和byte[]之间的转换 getBytes() Arrays工具类 : Arrays.toString(names) String类 String replace(char oldChar, char newChar) String replace(CharSequence target, CharSequence replacement) String[] split(String regex) boolean contains(CharSequence s):当且仅当此字符串包含指定的 char 值序列时,返回 true int indexOf(String str):返回指定子字符串在此字符串中第一次出现处的索引 int indexOf(String str, int fromIndex):返回指定子字符串在此字符串中第一次出现处的索引,从指定的索引开始 int lastIndexOf(String str):返回指定子字符串在此字符串中最右边出现处的索引 int lastIndexOf(String str, int fromIndex):返回指定子字符串在此字符串中最后一次出现处的索引,从指定的索引开始反向搜索 boolean endsWith(String suffix):测试此字符串是否以指定的后缀结束 boolean startsWith(String prefix):测试此字符串是否以指定的前缀开始 boolean startsWith(String prefix, int toffset):测试此字符串从指定索引开始的子字符串是否以指定前缀开始 int length():返回字符串的长度: return value.length char charAt(int index): 返回某索引处的字符return value[index] boolean isEmpty():判断是否是空字符串:return value.length == 0 String toLowerCase():使用默认语言环境,将 String 中的所有字符转换为小写 String toUpperCase():使用默认语言环境,将 String 中的所有字符转换为大写 String trim():返回字符串的副本,忽略前导空白和尾部空白 boolean equals(Object obj):比较字符串的内容是否相同 boolean equalsIgnoreCase(String anotherString):与equals方法类似,忽略大小写 String concat(String str):将指定字符串连接到此字符串的结尾。 等价于用“+” String substring(int beginIndex):返回一个新的字符串,它是此字符串的从beginIndex开始截取到最后的一个子字符串。 String substring(int beginIndex, int endIndex) :返回一个新字符串,它是此字符串从beginIndex开始截取到endIndex(不包含)的一个子字符串。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值