import java.util.Scanner; public static void main(String[] args) { Scanner n = new Scanner (System.in); String fio; System.out.print("Введите Фамилию :"); fio = n.nextLine(); System.out.println(fio); } 

Enter Last Name: Denis Ivanovich Ivanov

ASSEMBLY SUCCESSFULLY COMPLETED (total time: 19 seconds)

When entering Russian letters displays incomprehensible characters. How to fix? Tell me, if possible, for example, I work in NetBeans IDE 8.0.1.

  • In which development environment do you run the code? - Rams666
  • Good afternoon, in NetBeans IDE 8.0.1. Thanks in advance - Ayder

2 answers 2

Your problem is described here .

If you are writing to NetBeans, then you need to go to the project properties and change the encoding to windows-1251 . After that, this code works correctly:

enter image description here


Or, as an option, specify the encoding of the input characters immediately:

 public static void main(String[] args) throws UnsupportedEncodingException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in,"Cp1251")); System.out.println("Введите ФИО:"); //Scanner in = new Scanner(System.in); String s = br.readLine(); System.out.println(s); } 

    If you write in Netbeans -

    Scanner scanner = new Scanner (System.in, "Cp866");

    No problem will read Russian letters.