UTF-8 by default
Definition​
Since Java 18 the default character set of the JVM is UTF-8 on every operating system. Before, it depended on the machine (for example Windows-1252), so the same code could read text differently on different computers.
Example code​
The default charset is now always UTF-8
import java.nio.charset.Charset;
class Demo {
public static void main(String[] args) {
System.out.println(Charset.defaultCharset());
}
}
// Output:
// UTF-8
Finished this page? Track your progress (saved only in your browser).