SoFunction
Updated on 2025-02-28

Share the implementation code of java printing simple graphics

We usually use drawing tools to draw simple graphics. Today we use Java to print some simple graphics

The implementation code is as follows

 package test;
/**
  *
  * @author hanzel
  * @Print graphics
  *
  */
public class Array {
  public static void main(String[] args) {
    //Print rectangle    int[] a = new int[10];
    for(int i=0 ;i<;i++){
      for(int j=0;j<;j++){
        ("*");
      }
    ();
    }
    ();
    
    //Print inverted right triangle    int[] b = new int[10];
    for(int i=0 ;i<;i++){
      for(int j=0;j<-i;j++){
        ("*");
      }
    ();
    }
    ();
    
    // Another type of inverted right triangle    int[] e = new int[10];
    for(int i=0;i<;i++){
      for(int j=0;j<i;j++){
        (" ");        
      }
      for(int m=0;m<-i;m++){
        ("*");
      }  
    ();
    }
    ();
    
    //Print the parallelogram    int[] c = new int[10];
    for(int i=0;i<;i++){
      for(int j=0;j<i;j++){
        (" ");        
      }
      for(int m=0;m<;m++){
        ("*");
      }  
    ();
    }
    ();
    
    //Another parallelogram    int[] h = new int[10];
    for(int i=0 ;i<;i++){
      for(int j=0;j<-i;j++){
        (" ");        
      }
      for(int m=0; m<;m++){
        ("*");
      }
    ();
    }
    ();
    
    //Print right triangle    int[] d = new int[10];
    for(int i=0;i<;i++){
      for(int j=0;j<i;j++){
        ("*");        
      }
    ();
    }
    ();
    
    //Print another right triangle    int[] f = new int[10];
    for(int i=0;i<;i++){
      for(int j=0;j<-i;j++){
        (" ");    
      }
      for(int m=0;m<i;m++){
        ("*");    
      }
    ();
    }
    ();  
    
    
    //Print out a right-angle trapezoid    int[] g = new int[10];
    for(int i=0;i<;i++){
      for(int j=0;j<;j++){
        ("*");        
      }
      for(int m=0;m<i;m++){
        ("*");
      }  
    ();
    }
    ();

    //isosceles triangle    int[] k = new int[10];
    for(int i=0;i<;i++){
      for(int j=0;j<-i;j++){
        (" ");    
      }
      for(int m=0;m<2*(i+1)-1;m++){
        ("*");    
      }
    ();
    }
    ();
    //Another isosceles triangle    int[] l = new int[10];
    for(int i=0;i<;i++){
      for(int j=0;j<i;j++){
        (" ");        
      }
      for(int m=0;m<2*(-i)-1;m++){
        ("*");
      }  
    ();
    }
    ();  
  
    //diamond    int[] o = new int[10];
    for(int i=0;i<;i++){
      for(int j=0;j<-i;j++){
        (" ");    
      }
      for(int m=0;m<2*i-1;m++){
        ("*");    
      }
      ();
    }
    for(int i=0;i<;i++){
      for(int j=0;j<i;j++){
        (" ");        
      }
      for(int m=0;m<2*(-i)-1;m++){
        ("*");
      }  
      ();
    }
  }
}

The above is all about this article. This mini program is highly versatile and I hope it will be helpful to everyone's learning.