1 Packagetest;2 3 /**4 * content is output a hollow diamond5 * @authorA blind cat meets a dead tiger6 *7 */8 9 Public classlinxing {Ten One Public Static voidMain (string[] args) { A intN=15; - lingxing (n); - the } - - //outputs a diamond of n rows - Public Static voidLingxing (intN) { + //outputs the upper half of the first part - for(inti=0;i<n;i++) {//Output N Rows + for(intj=0;j<n+i;j++) {//print N+i characters per line A at if(j==n+i-1| | J==n-1-i) {//if it is the last character or a symmetrical position, the * number is displayed -System.out.print ("*"); -}Else{ -System.out.print (""); - } - in } - System.out.println (); to } + - //output Lower the for(inti=0;i<n-1;i++) {//Output n-1 Line * for(intj=0;j<2* (n-1)-i;j++) {//print per line (n-1)-I characters $ Panax Notoginseng if(j==2* (n-1)-i-1| | j==i+1) {//if it is the last character or a symmetrical position, the * number is displayed -System.out.print ("*"); the}Else{ +System.out.print (""); A } the + } - $ System.out.println (); $ } - - } the - Wuyi the}
"Dark Horse Programmer"-java Basic learning-output a hollow diamond