Source Code : Triangular array

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Triangular array

     
import java.text.Format;

public class TriangularArray {
public static void main(String[] args) {
    final int MAX_HIGH = 10;

    // allocate triangular array
    int[][] odds = new int[MAX_HIGH + 1][];
    for (int i = 0; i <= MAX_HIGH; i++)
      odds[i] = new int[i + 1];

    // fill triangular array
    for (int i = 0; i < odds.length; i++)
      for (int j = 0; j < odds[i].length; j++)
        odds[i][j] = i+j;

    // print triangular array
    for (int i = 0; i < odds.length; i++) {
      for (int j = 0; j < odds[i].length; j++){
        System.out.print(odds[i][j] + " ");  
      }
      System.out.println();
      
    }
  }
}
           
         
    
    
    
    
  

Thank with us