Hello All, (I made some changes to the program trying to use a void method instead of boolean.) This is just the foundation for a program that I am working on. The program is to ask the user to enter the amount of strings they would like in an array. The user then enters the array of strings. The program is then suppose to remove any words/strings containing "ch" and print them backwards. Right now I'm only searching for the letter 'A' though, since I currently can't remember how to search for two adjacent letters. The program won't compile because the Remove method sees x[i] as an int and not an array.
CODE
import java.util.*;
public class CH2 {
public static Scanner in = new Scanner (System.in);
public static void main (String[] args) {
String[] x = GetArray ();
}
public static String[] GetArray() {
int sz = -1;
while (sz<=0)
{System.out.print ("How many strings do you want in the array? ");
sz = in.nextInt();}
in.nextLine();
String[] array = new String [sz];
for (int i = 0; i < sz; i++) {
System.out.print ("Enter string "+(i+1)+": ");
array[i] = in.nextLine();
}
return array;
}
public static void Remove (String[] s) {
for (int x = 0; x < s.length; x++) {
for (int i = 0; i < s[x].length(); i++)
if (s[x].charAt(i) != 'A')
System.out.println (x[i]);
else
System.out.print ("");}
}
}
This post has been edited by JackSkell26: 8 Oct, 2007 - 05:08 PM