java中 输入字符串怎么给String数组赋值
importjava.util.Scanner;publicclassFileFilter{publicstaticvoidmain(String[]args){Scan...
import java.util.Scanner;
public class FileFilter{
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
String[] filenames=new String[2];
int i=0;
for(i=0;i<filenames.length;i++){
System.out.println("please input the string");
String text=scanner.next();
filenames[i]=text;}
System.out.println("output the filterfile:");
if(filenames[i].endsWith("jpg")){
System.out.println(filenames[i]);
}
}
}
这样做为什么不行呢 展开
public class FileFilter{
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
String[] filenames=new String[2];
int i=0;
for(i=0;i<filenames.length;i++){
System.out.println("please input the string");
String text=scanner.next();
filenames[i]=text;}
System.out.println("output the filterfile:");
if(filenames[i].endsWith("jpg")){
System.out.println(filenames[i]);
}
}
}
这样做为什么不行呢 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询