Hello, I'm new to java and I'm pretty bad at it. When I run my program it says array index out of bounds. I'm supposed to write a program that translates an English sentence to morse code with a driver and utility class. I have to read in a txt file that list the morse code translation like:
A .-
B -...
I tried reading in the txt file and then calling on a method in my utility class to store them in an array
(Driver)
(Utility)while(file.hasNext()) { int r=0; String q = file.nextLine(); utilty.setM(q,r); r++; }
(I made the array [26][2])
Then later to translate the code I call on a method in my utility class where I bring in g as a string argument (g is the next letter in the string I'm string to translate)
I'm sorry if this looks choppy, I just don't want to get accused of cheating so I only listed the parts I thought might be the problem. I just need a hint, thank you.int w=0; if(g==code[w][0]) { w=0; h=code[w][1]; } else { w++; }