![](/img/trans.png)
[英]Exception in thread “main” java.lang.RuntimeException: Uncompilable source code
[英]Java Errors: Exception in thread “main” java.lang.RuntimeException
我正在CMD中运行程序。
我正在使用2种方法将其打印出来,如下所示:
打印a和w之间的所有字符:
abcdefghij
克拉姆诺普斯特
紫外线
以下是我到目前为止所拥有的...但是我无法在这里过去。 我不断收到各种各样的错误。
public class Letters{
public static void main (String[] args) {
System.out.println("Print all characters between a and w");
for (char i = 0; i <= 10; i++) {
String myrow = printChars('a','w');
System.out.println(myrow);
}
}
public static void printChars (char c1, char c2){
}
}
首先,我建议适当缩进代码,以使其更易于阅读。 其次,在使用char时,您可以仅检查字符的值。 char c = 'a'
像这样。 如果增加c,则其值为b
。
public class Letters
{
public static void main (String[] args) {
System.out.println("Print all characters between a and w");
for (char c = 'a'; c <= 'w'; c++) {
System.out.print(c);
if ((c+1 - 'a') % 10 == 0) {
System.out.println();
}
}
System.out.println("\n");
printChars ('d','z');
}
public static void printChars (char c1, char c2) {
// no valid range, can also add checks to see if they are actual letters
if (c1 > c2) {
return;
}
System.out.println("Print all characters between " + c1 + " and " + c2);
for (char c = c1; c <= c2; c++) {
System.out.print(c);
if ((c+1 - c1) % 10 == 0) {
System.out.println();
}
}
}
}
这部分检查当前正在执行的迭代,然后检查该迭代是否可被10整除,以添加新行,否则将继续。
if ((c+1 - 'a') % 10 == 0) {
System.out.println();
}
public static void main( String[] args )
{
char c1='a';
char c2='w';
String str= "a b c d e f g h i j k l m n o p q s t u v w";
Pattern compile = Pattern.compile(".*"+c1+"(.*)"+c2+".*");
Matcher matcher = compile.matcher(str);
boolean found = matcher.find();
System.out.println("found:"+ found);
if (found) System.out.println(matcher.group(1));
}
E:\\ Java> jdk1.8.0_111 \\ bin> java -jar selenium-server-standalone-3.0.0.jar -htmlsuite“ * firefox” C:\\ Program Files(x86)\\ Mozilla Firefox \\ firefox.exe“” https ://www.google.com/ “” E:\\ Selenium \\ newsuite.html“” E:\\ Selenium \\ result.html“
我收到了上述error.please帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.