StringBuilder sb = new StringBuilder("sdfsf");
char d = 'd';
System.out.println(d);
sb.insert(0, d); //报错行
System.out.println(sb);
error message
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required. class files
at mi.TTT.main (TTT.java: 10)
------ Solution ---------------------- ----------------------
check jdk1.8 the API, see insert argument is not a change in what
- ----- Solution --------------------------------------------
source is how you look like . Why not .
------ Solution ------------------------------------ --------
is not being given elsewhere
looked API 8 of
StringBuilder insert (int offset, boolean b)
Inserts the string representation of the boolean argument into this sequence.
have this method , the parameter is not a problem .
your code and throws the stick full of exceptions , all the stickers out
------ Solution ------------- -------------------------------
tried it, no problem , java version "1.8.0"
------ For reference only ---------------------------------- -----
not changed, read the source code
/**
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
public StringBuilder insert(int offset, char c) {
super.insert(offset, c);
return this;
}
------ For reference only ----------------------------------- ----
package mi;
public class TTT
{
public static void main(String[] args)
{
StringBuilder sb = new StringBuilder("sdfsf");
char d = 'd';
System.out.println(d);
sb.insert(0, d);
System.out.println(sb);
}
}
------ For reference only ----------------------------------- ----
you did not install JDK well, you look at your project should contain a dozen jre8 jar file, if you do not it is not installed , or engineering problem set , no bar jre8 all library files added to it
------ For reference only ---------------------------------- -----
probably not installed right
------ For reference only ------------------------ ---------------
Well this is not without problems ?
------ For reference only -------------------------------------- -
Well, the reason is because I use eclipse compiled. eclipse compile and execute with the jdk6
with jre8
没有评论:
发表评论