Transferring One Dimensional to Two Dimensional String? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Transferring One Dimensional to Two Dimensional String?

This is ridiculously wrong: sentenceStr = verse.split("\\."); String [ ] [ ] superString; for (int x = 0; sentenceStr.length-1; x++) { superString [ ] [ ] = sentenceStr[x] } So... I'm new to multi dimensional arrays. I am making a program that reads any length of user input, splits each sentence (with periods), then splits each sentence (however many sentences there are) into different strings with split(" "). Any ideas on how to use a two dimensional array to hold as many (split) sentences as I need?

29th Mar 2018, 8:51 PM
Noah Shrewsbery
Noah Shrewsbery - avatar
2 Answers
+ 4
Well if i understood you, you want this: Get a verse input. then make an array which the first dimension means the word. e.g. verse= "This is cool"; arr[0] will represent the word and the second dimension will represent what char in the word. for example: arr[0,0]= T arr[0,1]=h arr[0,2]=i and so on... This is my code for it: https://code.sololearn.com/coBKBIFf46z8/#cs
29th Mar 2018, 10:35 PM
Tomer Sim
Tomer Sim - avatar
0
Thank you for the answer, but what I am trying to do is separate by sentences and by words for a verse memorizing program. Ultimately I want to do this: "This is a sentence. This is another sentence." becomes "This ___ a ____. This ___ another _____." And then the user fills in the blanks. My problem is that it wants to make a ____ place after the period (I'm using split(" "). So I need to make it seperate the sentences, then in each sentence separate the words.
2nd Apr 2018, 4:44 AM
Noah Shrewsbery
Noah Shrewsbery - avatar