The program does not read the characters of the Kazakh language (instead of them there are question marks), for example, "ғ", while correctly displaying the characters of the Russian alphabet, as well as some characters like "љ". All of them are Cyrillic Unicode. I used windows-1251 encoding, tried setting UTF-8 in the project properties, but he refused to accept anything at all and just translated to a new line.
package la6; import java.io.UnsupportedEncodingException; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Scanner; import java.util.Arrays; public class La6 { public static void main(String[] args) throws UnsupportedEncodingException { Scanner in = new Scanner(System.in, "windows-1251"); System.out.println("Enter ID's name: "); String str = in.nextLine(); if (isValidIdentifier(str)) { System.out.println("«" + str + "» - допустимое значение"); } else { System.out.println("«" + str + "» - недопустимое значение"); } System.out.println(); } public static boolean isValidIdentifier(String str) { if (!str.matches("[$_\u0401-\u04F9\u0041-\uFB06]+[$_0-9\u0401-\u04F9\u0041-\uFB06]+")) { return false; } String[] keyWords = {"boolean","volatile","else","instanceof","switch","true","goto","abstract","enum","int","static","false","break","assert","extends","interface","strictfp","null","continue","byte","final","long","super","do","case","finally","native","synchronized","double","catch","float","new","throw","protected","char","for","package","throws","this","class","if","private","transient","short","const","implements","public","try","while","default","import","return","void", "/", "\\","\""}; if (Arrays.asList(keyWords).contains(str)) { return false; } return true; } } Result:
run: Enter ID's name: ырҒ «ыр?» - недопустимое значение