Ok, first things first... the way your code looks on this forum made my eyes hurt while trying to figure out what it does. Try to use less newline and shorter indents.
As for the error, normally it comes with a line number so you should know at what line of code it errors.
An other thing, I see that in your for loops you try to match the string given by the user (i.e. combi) with one from the strings in the array dnas. Now, in your code the only thing that has happened to that array of strings is the following:
String dnas[] = new String[5];
That means, there are no strings in that array, you've never put anything in there.
This might not solve all your problems, but try to work with what I said and when you're stuck again, post a prettier version of the code please. It'll be easier to go through it. :)
Black Box
Black Box
Junior Poster in Training
62 posts since Nov 2007
Reputation Points: 60
Solved Threads: 7
It didn't read the file at all.. i really don't know how to import a file.. is my importing correct?
Ok, it's still the same error as before.
try {
fileReader=new BufferedReader(new FileReader("D://dna.txt"));
}
catch (IOException e) {
System.out.println("Error: File could not be opened.");
}
In that try block you contact the file you want to read and eventually the strings in there should be stored in the array dnas. But, you never tell Java to read from the file, let alone tell it to store it in dnas. You have only initialized the filereader in the try-block shown above, it is ready to read from the file, but you just don't do it.
Checkout the Java API for class FileReader to see how it works, it's fairly simple. Should you have questions, post them here.
And just a hint, since your reader is initialized in a try-block like it should, you should do the reading from the file (and the storing into dnas) in that same block, because your reader is only locally initialized.
Black Box
Black Box
Junior Poster in Training
62 posts since Nov 2007
Reputation Points: 60
Solved Threads: 7
keep in mind, that you're using a command line parameter to get the volume of the array... that may not be the easiest way to work with, since you have to know in front how many rows there are in your input file.
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
if (combi.equals(combi.toLowerCase()) || combi.equals(combi.toUpperCase()))
This statement in plain english reads:
if thisString equals thisStringConvertedToLowerCase or thisStringConvertedToUpperCase then...
This will ONLY be true if the entire string is written in lower or upper case. If there is any other combination of upper and lower case letters in your string it will return false.
I'm not 100% sure of what you are trying to do here...
darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200