我需要切断用户输入的字符串的一半。我已经尝试过了,但它没有用:
Scanner sc = new Scanner(System.in);
String nameOne = sc.nextLine();
chars[] oneChars = new char[nameOne.length];
double oneLength = oneChars.length / 2;
Math.round(oneLength);
int oneLen = (int)oneLength;
String nameOneFinal = "";
for(int i = 0; i == oneLen--; i++) {
oneChars[i] = oneChars[oneLen];
nameOneFinal = nameOneFinal + oneChars[i];
}