I am trying to figure out how to print out w1 and w2 at the point it crosses like so:
b
l ottery
a
t
.... and so on

Here is my code.

public class Assg2
{
    public static void main(String[] args)
    {

            String w1 = args[0];
            String w2 = args[1];

            int numberOfCrosses = 0;

        int pos1 = 0;
            int pos2 = 0;


            for(int i=0; i < w1.length(); i++)
            {
                for(int j=0; j < w2.length(); j++)
                {   
                    if(w1.charAt(i) == w2.charAt(j))
                    {
                        numberOfCrosses++;
                        System.out.println(w1 + " " + w2);
                    }
                }
            }

        if(numberOfCrosses == 0)
        {
            System.out.println("Words do not cross");
        }
    }

    private static boolean crossesAt(String w1, int pos1, String w2, int pos2)
    {
        if(w1.charAt(pos1) == w2.charAt(pos2))
        {
            return true;
        }
        else
        {
            return false;
        }

    }

    private static void printCross(String w1, int pos1, String w2, int pos2)
    {
        for(int i=0; i < w1.length(); i++)
        {
            for(int j = 0; j < w2.length(); j++)
            {


            }
        }



    }



}

This looks familiar. What are lines 10 and 11 for?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.