获得日语单词的最后两个字符返回Netbeans 8.2中的问号



我有此代码:

String str;
Scanner Lectura = new Scanner(System.in);
System.out.print("Type a word in plain form: ");
str=Lectura.next();
//obtains word
String substring = str.length() > 2 ? str.substring(str.length() - 2) : str;
System.out.print(substring);

...获取单词的最后两个数字。我打算将其与日语动词一起使用,但由于某种原因,它只是返回问号:

https://i.stack.imgur.com/3e7c2.png

i在食べる中键入togry应该返回べる;最后两个字符。这是证明它不是一个Unicode问题或其他问题(控制台字体太小):

https://i.stack.imgur.com/dthez.png

有什么问题?我该怎么做才能获得这些角色而不是问号?

我想扫描仪正在使用您的系统的默认编码?您的样本对我有用(我的操作系统上有UTF-8 ...)您可以在创建扫描仪时指定编码,也许会有所帮助?

Scanner Lectura = new Scanner(System.in, "UTF-8");

相关内容

最新更新