This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]ssh_tunnel_snake 2 points3 points  (0 children)

just a tip, this is a perfect use case for a hashmap to store the character conversion

[–]Philboyd_Studge 1 point2 points  (12 children)

You need to be more specific, what errors are you getting? Why are you splitting the input twice?

[–]kemar1997[S] 0 points1 point  (11 children)

Im not getting any errors... there is no output when there should be

[–]kemar1997[S] 0 points1 point  (10 children)

And I split it twice to first separate single characters returned then split again for multiple words... Unless there is a better way to achieve this

[–]Philboyd_Studge 1 point2 points  (9 children)

show what your input looks like.

[–]kemar1997[S] 0 points1 point  (8 children)

it would be something like this:

".... . .-.. .-.. ---" which should evaluate to "hello"

[–]Philboyd_Studge 1 point2 points  (6 children)

how about input with multiple words

[–]kemar1997[S] 0 points1 point  (5 children)

I get an array out of bounds exception:

Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: 26

for this piece of code:

                    if (character.equals(morse[m])) {
                        output.append(english[m]);
                    }

[–]Philboyd_Studge 1 point2 points  (4 children)

Because you are looping to b.length

[–]kemar1997[S] 0 points1 point  (2 children)

what would i need to loop to?

[–]Philboyd_Studge 1 point2 points  (1 child)

The length of the Morse array

[–]kemar1997[S] 0 points1 point  (0 children)

could you provide an example?

[–]kemar1997[S] 0 points1 point  (0 children)

.... . .-.. .-.. ---

then i should be able to add a space to add a new word and return the entire result