#Compilation error when running any code with an import statement

1 messages · Page 1 of 1 (latest)

misty goblet
#

Hi, I am trying to run this code:

package org.example;// Q02c

import java.util.Random;

public class Q02c
{

    public static void main (String[] args)
    {
        int width = 0;
        int length = 4;
        int perimeter = 0;
        Random randGenerator = new Random();
        
        width = randGenerator.nextInt(1, 6);
        perimeter = (2 * width) + (2 * length);
        
        System.out.println (String.valueOf(width) + " " +
                        String.valueOf(length) + " " +
                        String.valueOf(perimeter));  
    }
}

And I keep getting this error:

/Users/a/Desktop/CSTemporary/src/main/java/org/example/Q02c.java
java: illegal character: '\ufeff'
/Users/a/Desktop/CSTemporary/src/main/java/org/example/Q02c.java
java: class, interface, enum, or record expected
/Users/a/Desktop/CSTemporary/src/main/java/org/example/Q02c.java:3
java: class, interface, enum, or record expected

errant ruinBOT
# misty goblet Hi, I am trying to run this code: ```java package org.example;// Q02c import j...

Detected code, here are some useful tools:

[WARNING] The code couldn't end properly...

Problematic source code:

package org.example;// Q02c

import java.util.Random;

public class Q02c
{

    public static void main (String[] args)
    {
        int width = 0;
        int length = 4;
        int perimeter = 0;
        Random randGenerator = new Random();
        
        width = randGenerator.nextInt(1, 6);
        perimeter = (2 * width) + (2 * length);
        
        System.out.println (String.valueOf(width) + " " +
                        String.valueOf(length) + " " +
                        String.valueOf(perimeter));  
    }
}```
Cause:
The code doesn't compile:
illegal start of expression

## System out
[Nothing]
#

<@&987246527741304832> please have a look, thanks.

misty goblet
#

I am using Intellij*

balmy wigeon
#

you may have an encoding problem or a blank shitty char, i tried it and it's working

misty goblet
#

I ran it in tj bot and it also says this

Cause:
The code doesn't compile:
illegal start of expression

#

I think its because of the import statement, because in the code files where there is no import everything works perfectly

misty canyon
#

Try googling 'java: illegal character: '\ufeff''

misty goblet
#

What does BOM mean?

misty canyon
#

again, keep googling.