Rob Rowan wrote: . . . (exactly like countdown) . . .
And you want us to help with your claim it is cruel and unnatural punishment under the Geneva Convention. Of course!
No, it is a programming thing. Welcome to the Ranch
I would suggest
you should get that code out of the main method, but I suspect you know that already and simply had it there until it works. You would appear to have programmed in C before, with so much in the main method, and using _ in variable names. We use
different conventions in
Java.
I am not quite sure what the problem is. Are you having difficulty reading into an array? Just having a quick look at your code, I can see a few other things.
1: Do you ever use the Arrays class? I don’t think you need that import.2: You don’t need the two Strings line and Dictionary. To get rid of them, you will probably have to learn some strange‑looking syntax:-I would use a List myself, not an array, but you may not have come across Lists yet. How do you know the array is the right size? If it is too small you will get an out of bounds exception when you get to the 90001st line. If it is too large, you may suffer a null exception when you get to the last array element, which will be null. Suggestion:-
1: Create reader2: Read every line in the file, doing nothing with it.3: Close reader.4: Create new reader.5: Read each line into the array6: Close second reader.You are doing nothing with the lines from the first reader, but I omitted to write that you can count them. Then you will know what size the array will be.
As for working out whether a
word matches the letters, that can be awkward. Can you work out how to get arrays of chars out of a String? Do you need to sort those arrays? Can you work out how to tell that one array represent a subset of the other? You cannot do that on screen until after you have written down on paper how you intend to do it. Good luck, and do tell us how you are getting on with it.