# Thread: Question on substring division and sorting to arrays

1. Member
Join Date
Nov 2013
Posts
4
Rep Power
0

## Question on substring division and sorting to arrays

Currently working on the bog-standard Meyers-Briggs array project.

I have the idea of taking the string of 70 inputs and slicing them down via a substring. The substring divider part, I think I have done correctly, however my sticking point is taking that substring and sorting it's 7 input values to one of four arrays, I'm not entirely sure of how to do this.

My current work on my "sectionCutter" is rough starting at line 19 but, thus:

Java Code:
```public class sectionCutter {
public static void sectionCutter(String[] args){
String results = "BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA";
int i = 0;
int s = 0;
char[] EvsI = new char[10];
char[] SvsN = new char[20];
char[] TvsF = new char[20];
char[] JvsP = new char[20];
while(i < results.length());{
String divider = results.substring(i, i + 7);
System.out.println(divider);
i += 7;
divider.charAt(i);

for(s > divider.length(); s++){
if(s){
}
if(int s = 1){}
if(int s = 2,3){}
if(int s = 4,5){}
if(int s = 6,7){}
if(divider.charAt(s)){

}
}

}
}
}```
The most ideal help would just be the syntax for an iterator that counts and then sorts to different arrays, I've been enjoying the exercise so far but this idea for how I want to implement the "sorter" is totally kicking my ass.

- Many thanks, Thurokiir
Last edited by Thurokiir; 11-13-2013 at 05:05 AM. Reason: Updating Syntax

2. ## Re: Question on substring division and sorting to arrays

counts and then sorts to different arrays
Can you explain what is to be counted and how the Strings are to be sorted and stored in the different arrays?

3. Member
Join Date
Nov 2013
Posts
4
Rep Power
0

## Re: Question on substring division and sorting to arrays

Originally Posted by Norm
Can you explain what is to be counted and how the Strings are to be sorted and stored in the different arrays?
Certainly!

I'm given a long string of user inputs to multiple choice questions:
bbbaaabbbbaaba-BAAAABBABBAAABBAABAAB-AAAAABBBABAABABA-ABBBABBABAA-AAAA
These multiple choice questions are always in the same order in respect to one of four question categories:
1223344

The original string is 70 characters long, the multiple choice pattern is in sets of 7. So my plan in so far is to process the long string into chunks of 7 via a while loop substring. I THINK I have that down, the hard part at the moment for me is to send the 7 user inputs that I have gathered via my substring method and send them back to one of four arrays.

Does that clear anything up?
Last edited by Thurokiir; 11-13-2013 at 04:03 AM. Reason: Clarity

4. ## Re: Question on substring division and sorting to arrays

The question I was asking was: what is to be done with the group of 7 character Strings? You mention counting and sorting? What is counted and how are they sorted?

5. Member
Join Date
Nov 2013
Posts
4
Rep Power
0

## Re: Question on substring division and sorting to arrays

Each group of seven follows a pattern of what arrays I want to send the values to, 1 22 33 44. I want to iterate through the group of seven then as I count each value, I want to send that value to an array.

Currently I have a guess of
if(s = 1){
then(System.out.println(String.toArray(EvsI));

I think that does what I want, sends the character value of when S = 1 to the Array EvsI. I'm not totally sure though, the syntax is eluding me pretty hard here.
Last edited by Thurokiir; 11-13-2013 at 04:39 AM. Reason: Also answering a question.

6. ## Re: Question on substring division and sorting to arrays

the syntax is eluding me
Are you having problems with coding an if statement? Take a look at the tutorial:
The if-then and if-then-else Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)

7. Member
Join Date
Nov 2013
Posts
4
Rep Power
0

## Re: Question on substring division and sorting to arrays

The if statement is not my big issue, it is identifying a letter within each substring iteration and sending it to a corresponding array based on the 1223344 pattern.

8. ## Re: Question on substring division and sorting to arrays

identifying a letter within each substring iteration and sending it to a corresponding array based on the 1223344 pattern.
What are the rules for that? How is a letter identified and what array corresponds to it? How is the 1223344 pattern used?

9. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,004
Rep Power
11

## Re: Question on substring division and sorting to arrays

I have been following this thread and I still don't understand the problem. Are a's and b's the answers to questions? Are A's and a's the same -- see item #3. What is the significance of 1223344? Does 1,22,33,and 44 identify one of the four arrays? If so, why those particular numbers and not 1,2,3, and 4? And why are three of your arrays of size 20 and the first is of size 10? For use to help you it really helps us to understand the requirements of the problem.

Regards,
Jim

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•