Java 运行时异常-功能尚未实现

Java 运行时异常-功能尚未实现,java,runtimeexception,Java,Runtimeexception,下面的代码块在jelliot中显示了此错误“运行时异常-功能尚未实现”,当它到达行时 char arr [] = w.toCharArray(); 在其他编译器中,它不会接受它应该接受的输入数量。如果我设置n=4,它只需要2个输入 Scanner Sc = new Scanner (System.in); int n = Sc.nextInt(); for(int count = 1;count<=n; count++){ String w = S

下面的代码块在jelliot中显示了此错误“运行时异常-功能尚未实现”,当它到达行时

char arr [] = w.toCharArray();
在其他编译器中,它不会接受它应该接受的输入数量。如果我设置n=4,它只需要2个输入

    Scanner Sc = new Scanner (System.in);
    int n = Sc.nextInt();
    for(int count = 1;count<=n; count++){
        String w = Sc.nextLine();
        char arr [] = w.toCharArray();
        if(arr.length > 4){
            System.out.print(arr[0]);
            System.out.print(arr.length-2);
            System.out.print(arr[arr.length-1]);
        }
        else{
            System.out.println(w);
        }
        System.out.println();
    }
Scanner Sc=新扫描仪(System.in);
int n=Sc.nextInt();
用于(整数计数=1;计数4){
系统输出打印(arr[0]);
系统输出打印(arr.length-2);
系统输出打印(arr[arr.length-1]);
}
否则{
系统输出打印LN(w);
}
System.out.println();
}

异常表明
String
类的这个特殊方法(
tocharray()
)没有为您正在使用的java实现(可能是非标准的)而实现。您可以通过不使用字符数组,而是使用
String
方法
length()
charAt()
来解决这个问题。试试这个:

Scanner Sc = new Scanner (System.in);
int n = Sc.nextInt();
for(int count = 1;count<=n; count++){
    String w = Sc.nextLine();
    if(w.length() > 4){
        System.out.print(w.charAt(0));
        System.out.print(w.length()-2);
        System.out.print(w.chatAt(w.length()-1));
    }
    else{
        System.out.println(w);
    }
    System.out.println();
}
Scanner Sc=新扫描仪(System.in);
int n=Sc.nextInt();
用于(整数计数=1;计数4){
系统输出打印(w.charAt(0));
系统输出打印(w.长度()-2);
系统输出打印(w.chatAt(w.length()-1));
}
否则{
系统输出打印LN(w);
}
System.out.println();
}

异常表明
String
类的这个特殊方法(
tocharray()
)没有为您正在使用的java实现(可能是非标准的)而实现。您可以通过不使用字符数组,而是使用
String
方法
length()
charAt()
来解决这个问题。试试这个:

Scanner Sc = new Scanner (System.in);
int n = Sc.nextInt();
for(int count = 1;count<=n; count++){
    String w = Sc.nextLine();
    if(w.length() > 4){
        System.out.print(w.charAt(0));
        System.out.print(w.length()-2);
        System.out.print(w.chatAt(w.length()-1));
    }
    else{
        System.out.println(w);
    }
    System.out.println();
}
Scanner Sc=新扫描仪(System.in);
int n=Sc.nextInt();
用于(整数计数=1;计数4){
系统输出打印(w.charAt(0));
系统输出打印(w.长度()-2);
系统输出打印(w.chatAt(w.length()-1));
}
否则{
系统输出打印LN(w);
}
System.out.println();
}

如果我设置n=4,它只需要2个输入。
似乎需要3个输入,并且您使用的java版本不支持
CharArray
?您能解释一下“jeliot”是什么(以及您使用的版本)吗?看起来是某个库/应用程序不完全支持您尝试执行的操作。它设置为count“Jeliot3是一个程序可视化应用程序。它可视化了Java程序的解释方式。方法调用、变量和操作在动画进行时显示在屏幕上,允许学生逐步跟踪程序的执行。程序可以从头开始创建,也可以从以前存储的代码示例中修改。正在制作动画的Java程序不需要任何类型的附加调用,所有可视化都是自动生成的。Jeliot 3了解大多数Java结构,并且能够对它们进行动画制作“我使用的是版本3@StefanFreitagfirst,您说它需要
2输入
,然后在您的else语句中尝试这个方法,您按下enter键“
如果我设置n=4,它只需要2个输入。
似乎需要3个输入,并且您使用的是哪个java版本,不支持
CharArray
?您能解释一下“jeliot”是什么(以及您使用的是哪个版本)吗?”?看起来是某个库/应用程序不完全支持您尝试执行的操作。它设置为count“Jeliot3是一个程序可视化应用程序。它可视化了Java程序的解释方式。方法调用、变量和操作在动画进行时显示在屏幕上,允许学生逐步跟踪程序的执行。程序可以从头开始创建,也可以从以前存储的代码示例中修改。正在制作动画的Java程序不需要任何类型的附加调用,所有可视化都是自动生成的。Jeliot 3了解大多数Java构造,并且能够对它们进行动画制作“我使用的是版本3@StefanFreitagfirst,你说它需要
2输入
,然后在你的else语句
w+“你按下回车键”