I'm trying to make a program that reads two English words from the command line, and then prints out all the possible ways that words can cross each other. and print an error message if they do not overlap. I want to use the charAt and length methods. I donβt know where to even start ..
here is what i got so far:
public class Cross2
{
public static void main(String[] args)
{
private String[][] cross = new String[w1pos][w2pos];
Scanner input = new Scanner(System.in);
System.out.println("Enter two words: ");
String word1 = input.next();
String word2 = input.next();
for(int w1pos = 0; w1pos < word1.length(); w1pos++) {
for(int w2pos = 0; w2pos < word2.length(); w2pos++) {
if (word1.charAt(w1pos) == word2.charAt(w2pos))
System.out.println(cross[w1pos][w2pos]);
}
}
source
share