1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import java.util.*; class StringArrayTest { public static void main(String [] args) { Scanner scan = new Scanner(System.in); String[] lolArray = new String[6]; lolArray[0] = scan.nextLine(); lolArray[1] = scan.nextLine(); lolArray[4] = "Dylan is watching me"; for (int index = 0 ; index < lolArray.length ; index++ ) { if (lolArray[index] != (null) ) { System.out.println(lolArray[index]); } else { System.out.println("There is nothing."); } } } } |
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgU3RyaW5nQXJyYXlUZXN0CnsKICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgW10gYXJncykKICB7CgogICAgU2Nhbm5lciBzY2FuID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCiAgICBTdHJpbmdbXSBsb2xBcnJheSA9IG5ldyBTdHJpbmdbNl07CgogICAgbG9sQXJyYXlbMF0gPSBzY2FuLm5leHRMaW5lKCk7CiAgICBsb2xBcnJheVsxXSA9IHNjYW4ubmV4dExpbmUoKTsKICAgIGxvbEFycmF5WzRdID0gIkR5bGFuIGlzIHdhdGNoaW5nIG1lIjsKCgogICAgZm9yIChpbnQgaW5kZXggPSAwIDsgaW5kZXggPCBsb2xBcnJheS5sZW5ndGggOyBpbmRleCsrICkKICAgIHsKICAgICAgaWYgKGxvbEFycmF5W2luZGV4XSAhPSAobnVsbCkgKQogICAgICAgewogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4obG9sQXJyYXlbaW5kZXhdKTsKICAgICAgIH0KICAgICAgZWxzZQogICAgICAgewogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlRoZXJlIGlzIG5vdGhpbmcuIik7CiAgICAgICB9CiAgICB9CgogIH0KfQ==
-
upload with new input
-
result: Success time: 0.1s memory: 212864 kB returned value: 0
frlgkjahflcghaldchglakdjfhglajkdhcglajhdgc lol
frlgkjahflcghaldchglakdjfhglajkdhcglajhdgc lol There is nothing. There is nothing. Dylan is watching me There is nothing.
-
result: Success time: 0.1s memory: 212864 kB returned value: 0
stuff goes here that isn't computer repair
stuff goes here that isn't computer repair There is nothing. There is nothing. Dylan is watching me There is nothing.
-
result: Runtime error time: 0.11s memory: 212864 kB signal: -1
Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1516) at StringArrayTest.main(Main.java:12)



