
Problem : Write a Java class having a String array, with global visibility. Add a method that adds a given sting to the string array. Add a method that searches for a given string in the string array. Add a method that searches for a given character in the string array. The method should count and returns the occurrence of the given character. Write an appropriate main method to test these class methods.
here is my solution where i reach so far:
package ooplab3;
public class StringArray {
String[]sTA=null;
private int index=0; //last adding string postion in String array
public static String [] testArray; {
}
public void setCounter(int counter) {
this.index = counter;
}
public String getsTA index(int i) {
return sTA;
}
public void AddStringtoArray(String st) {
if(this.index < sTA.length){
sTA[this.index]=st;
this.index++;
}
}
public int searchStringInArray(String sT, int i){
int n=0;
for(int i=0; i<this.index;i++)
for(int j=0;j<10;j++)
sTA[i].indexOf(sT);
n+=searchInString(sTA[i]);
return 0;
}
public int searchcharInArray(String sT){
int n=0;
int Startindex=0;
do{
n+=sT.indexOf(occ,starindex);
}
{
while(next !=(int)'\n')
{
outfile.print((char)(next));
return n;
}
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.