Illegal character with Blue J

2019-07-29 10:56发布

Program

public class Project_X
{
   public static void main(String[] args){

      byte x;
      int a=270;
      double b =128.128;

      System.out.println("int converted to byte");
      x=(byte) a;

      System.out.println("a and x "+ a +" "+x);
      System.out.println("double converted to int");

      a=(int) b;

      System.out.println("b and a "+ b +" "+a);
      System.out.println("n double converted to byte");

      x=(byte) b;

      System.out.println("b and x "+b +" "+x);
   }
}

error get

illegal character:\160

2条回答
Lonely孤独者°
2楼-- · 2019-07-29 11:32

You copy-pasted the program code using a tool (probably a web browser) that includes "funky" symbols in copied text. E.g. the non-breaking space.

One way to expose these characters is the following:

  1. Go to http://www.asciitohex.com/
  2. Copy-paste your code into the input box
  3. Click on convert
  4. Copy paste text from "Html Entities" output on lower right corner
  5. Remove all  -s and other strange things from code
查看更多
迷人小祖宗
3楼-- · 2019-07-29 11:37

\u160 is the non-breaking space. Have you tried deleting and retyping the line?

查看更多
登录 后发表回答