题解 | #截取字符串#
截取字符串
https://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNextLine()){
String str = in.nextLine();
int len = Integer.parseInt(in.nextLine());
String resStr = str.substring(0,len);
System.out.println(resStr);
}
}
}
基恩士成长空间 444人发布
