i'm trying to make a program that reads two English words from the command line, then outputs all possible ways the words can cross eachother. and print an error message if they do not cross. i want to use the charAt and length methods.. not sure where to even start..
here's what i got so far:
public class Cross2
{
public static void main(String[] args)
{
// create two dimentional array that stores input
private String[][] cross = new String[w1pos][w2pos];
// get input from user
Scanner input = new Scanner(System.in);
System.out.println("Enter two words: ");
String word1 = input.next();
String word2 = input.next();
// loop through length of words
for(int w1pos = 0; w1pos < word1.length(); w1pos++) {
for(int w2pos = 0; w2pos < word2.length(); w2pos++) {
// if characters are equal, print the array
if (word1.charAt(w1pos) == word2.charAt(w2pos))
System.out.println(cross[w1pos][w2pos]);
}
}