Answers for "cartesian product of two sets in java"

1

cartesian product of two sets in java

public class TheCartesianProduct{

  public static void main(String[] args) {
    
  int number[] = {1,2,3};
  char letter[] = {'A', 'B', 'C'};
  int numLength = number.length;
  int letLength = letter.length;

    for (int i = 0; i < numLength; i++){
        //run loop changes [i] three times
        for ( int j = 0; j < letLength ; j++){  
            //run loop [j] 3*3= 9 times 
            System.out.print("(" + letter[i] + " ," + number[j] +"), ")
            //print [i] and [j] at each interavel total of 9 times 
        }//close nested  for
    }//close for
  }//close main
}//Close class
Posted by: Guest on October-13-2021

Code answers related to "cartesian product of two sets in java"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language