【问题标题】:Illegal Character error: '\u200b'非法字符错误:'\u200b'
【发布时间】:2016-06-10 00:24:30
【问题描述】:

我正在我的面向对象编程课程中为 Asteroid 游戏制作 Asteroid Field,我收到一个非法字符错误:'\u200b'。问题似乎发生在第 12 行。(import java.awt.Point; 和 public class Asteroid extends PolyBlob 之间的线)

/*
 * University of Central Florida
 * COP3330 - Spring 2016
 * Author: Aundray Ortiz
 */
package asteroidfield;

import java.util.Random;
import blobzx.PolyBlob;
import blobzx.BlobUtils;
import java.awt.Point;
​
public class Asteroid extends PolyBlob
{
    private static final Random random = new Random();

    public Asteroid(int a, int b, double c)
    {
        super(-100,-100,c);
        int sides = 5 + random.nextInt(5);
        int[] x = new int[sides];
        int[] y = new int[sides];
        int going = 0;
        double direct = 0;
        double region = (Math.PI * 2)/sides;
        for(int num = 0; num<sides;num++)
        {
            going = 5 + random.nextInt(16);
            direct = (num * region) + (Math.random() * region);
            Point p = BlobUtils.rotatePoint(going, direct);
            x[num] = p.x;
            y[num] = p.y;
        }

        setPolygon(x, y);
        setRate(c);
        setDelta(a,b);
    }
}

【问题讨论】:

    标签: java netbeans illegal-characters


    【解决方案1】:

    \u200b 是 Unicode 中的“零宽度空间”。

    您应该删除第 12 行(空白行),保存文件,重新添加空白行并再次保存。使用简单的文本编辑器。

    如果这不能解决问题,请删除第 11 行和第 13 行并重新创建它们。

    【讨论】:

      【解决方案2】:

      我认为这里的重点是不要重新输入复制的代码。所以考虑到这一点:

      步骤:

      1- Ctrl + r 替换(勾选Regex复选框)

      2-粘贴字符代码:\u200b

      3- 全部替换

      完成!

      【讨论】:

        猜你喜欢
        • 2013-01-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-22
        • 2016-03-10
        • 2016-04-07
        • 2015-01-06
        相关资源
        最近更新 更多