Question: I print hindi characters as string in java and I'm getting an error. I save the java file in notepad uing UTF-8.

```
public class MainClass {
    public static void main(String args[]) throws Exception {
        String s = "साहिलसाहिल";

        System.out.print(s);
    }
}

```

After compilation, I get 2 errors of illegal character. Why so?

Answer: 
try it with

`java -Dfile.encoding=UTF8 MainClass.java`
You need to save the source file in UTF-8 format (easy to do it using Notepad++ or Eclipse IDE) and then compile with the `-encoding` switch to `javac`.

```
javac -encoding utf8 MainClass.java

```