Is this syntax possible?
for (int counter=o,charArray[0]; counter <=10,charArray[] <=0; counter++, charArray[]++)
I am asking this since I am having a hard time with the code I'm making. I'mplaying around with a string searching code and I want to use that for the following text file with this content:
KA-MA-NA-PA-QA
AA-DA-IA-MA
AA-BA-DA-EA-FA-HA
DA-EA-IA-MA-NA
EA-GA-HA-JA-PA-QA
BA-GA-IA-MA-LA
BA-EA-IA-KA-LA-PA
AA-FA-JA-KA-LA
CA-GA-HA-LA-MA
CA-EA-FA-GA-LA-PA
BA-CA-JA-MA
BA-DA-GA-HA-IA-KA
AA-FA-MA-OA-PA
CA-FA-HA-IA-JA-PA
AA-JA-LA-NA-QA
AA-BA-CA-IA-NA-QA
IA-JA-MA-PA
CA-DA-FA-GA-HA-QA
HA-IA-KA-LA-NA
FA-MA-OA-PA
EA-GA-LA-OA-QA
BA-EA-GA-IA-QA
AA-HA-IA-MA-PA
CA-DA-KA-OA-PA
What I intended for the source code I made is that it should search through only 12 lines in the file, instead of all 24 lines, for any repeating occurrence of a character. From what I did, the code goes through the entire list 12 times instead of going through 12 lines for one loop only. I believed that only a "for" loop can achieve the action I want - though I don't know where in the code I should place it. By the way, I included the code below:
import java.io.*; import java.util.*; public class stringsearch{ public static void main (String args [])throws IOException { Scanner search = new Scanner (new File ("stringtext.txt")); int counterA=0; int counterB=0; int counterC=0; int counterD=0; int counterE=0; int counterF=0; int counterG=0; int counterH=0; int counterI=0; int counterJ=0; int counterK=0; int counterL=0; int counterM=0; int counterN=0; int counterO=0; int counterP=0; int counterQ=0; int arrayindex=0; while (search.hasNextLine()) { //while loop starting brace String scanline = search.nextLine(); String [] charArray = scanline.split("-"); for (int counter=0; counter<=42; counter++) { // for loop starting brace if (charArray[arrayindex].equals("AA")) { //first main outer if loop starting brace counterA++; if (counterA>=3) { System.out.println ("AA is very common"); } else { System.out.println ("AA is least common"); } } //first main outer if loop ending brace else if (charArray[arrayindex].equals("BA")) { //second main outer if loop starting brace counterB++; if (cluster_B_counter>=3) { System.out.println ("BA is very common"); } else { System.out.println ("BA is very common"); } } //second main outer if loop ending brace } // for loop ending brace }//while loop ending brace } }
Do you have any suggestions on how I should make the code work the way I want it?