Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)
Hollow Rhombus Star Pattern Java Program
Latest :

Hollow Rhombus Star Pattern Java Program

Java program to print Hollow rhombus star pattern program. We have written below the print/draw Hollow rhombus asterisk/star pattern program in four different ways with sample example and output, check it out. At the end of the program, we have added compiler so that you can execute the below codes.

  • Using For Loop
  • Using While Loop
  • Using Do While Loop

 Using For Loop

1) Read entered value store it in the variable n.

2) The outer for loop iterate through rows with the structure for(int i=1;i<=n;i++) and run the inner loops to iterate through columns.

3) The outer for loop iterates from i=1 to i=n, the 1st inner for loop iterates with the structure for(int j=1;j<=n-i;j++) and prints space if j<=n-i is true.

4) 2nd inner for loop prints characters from j=1 to j=n, if i==1 or i==n

if i!=1 || i!=n then 3rd inner loop prints characters if j=1 or j=n otherwise prints space.

next cursor comes to next line and i value increased, i=2 the condition at outer loop is true if the condition is false for i=2 so comes to else part, the for loop prints character for j=1 and j=5. Prints spaces for j=2, 3, 4.

  • After all iterations, the complete pattern will be printed.

Output:

Using While Loop

1) Check the condition at outer while for the given i value, if this condition is true then j=1 .

2) The 1st inner while loop prints spaces until while(j++<=n-i) is false.

3) If if(i==1 || i==n) is  

a) true then 2nd inner loop prints character until while(j <=n) the condition is false.

b) false the 3rd inner loop prints character until while(j<=n) is false if j=1 or j=n, otherwise it prints space for j!=1, n.

Output:

Using Do-While Loop

1) The outer do loop starts the execution j=1, the 1st inner do loop prints one space then checks the condition while(j++<=n-i), if this condition is true it prints character until the condition is false.

a) true then inner do loop prints one character then checks the condition while(++j <=n), if this condition is true then it prints the character until the condition is true.

b) false the do loop prints character if j=1 or j=n is true otherwise prints space and then checks the condition while(++j<=n). If it is true then it executes the code, repeats until while(++j<=n) is false.

3) Cursor comes to next line and i value increased by 1 and then checks the condition at outer do-while loop while (i<=n), repeats until the condition while(i<=n)is false.

Output:

x

Check Also

Java Program To Calculate Exponent Value | 4 Ways

Java program to calculate exponent – In this article, we will brief in on all ...

atakoy escortatakoy escortbakırköy escortşişli escortbağcılar escortsightcaredeneme bonusu veren sitelerromabetdeneme bonusu veren sitelerdeneme bonusu veren sitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren Sitelersekabetdeneme bonusu veren sitelergrandpashabetgrandpashabetGrandpashabetdeneme bonusu veren sitelerdeneme bonusu veren sitelercasibomcasibom güncel girişdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelercasinofastbetwoonroyalbetdeneme bonusugrandpashabetdeneme bonusu veren sitelermarsbahis girişvaycasino girişmadridbetdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerromabetistanbul escortgrandpashabetgrandpashabetgrandpashabetgrandpashabetelitcasinocasibomjojobetcasibomcasibom girişcasibom girişcasibomgrandpashabetcasibom girişcasibomcasibom girişcasibomcasibom güncel girişcasibomcasibom girişcasibomcasibom girişcasibom girişcasibom güncel girişgrandpashabetgrandpashabet girişgrandpashabetgrandpashabet girişbetgray güncel girişvdcasinograndpashabetgrandpashabetgrandpashabetgrandpashabetgrandpashabetGrandpashabetzbahiscasibom girişcasibom girişcasibom girişdeneme bonusubetcio girişbetnano girişdeneme bonusu veren sitelerRokubetjojobetDeneme Bonusu Veren SitelerjojobetcasibompadişahbetjojobetjcknepadişahbetBetsatVdcasinorotabetsekabetHoliganbetzbahiszbahisotobetnakitbahiskingroyalkingroyalmadridbetmadridbettarafbet토토사이트avrupabetmarsbahisLefkoşa İngilizce KursuportobettimebettimebetdizipalRokubet girişcasibombetparkbetparkcasibomcasibomcasibommeybetbetpuancasibom girişzbahiscasibommatbet girişvdcasino giriştempobetpusulabet girişgrandpashabet girişmeritking girişgrandpashabet girişmeritking girişbahiscom girişonwinmatadorbetjojobetsahabetmatadorbetonwinsahabetsahabet girişjojobet girişsahabetgrandpashabet girişsahabetsahabetonwin güncel girişonwinonwinonwincasibomcasibomcasibomcasibom girişcasibomcasibom girişholiganbetpusulabetbetboobetparktempobetextrabetgrandpashabetbetpuansahabet güncel girişonwinmatadorbetholiganbetsahabetkralbet girişkralbetsahabetsahabet güncel girişsahabet güncel girişpusulabetmatadorbetbets10bets10 girişpusulabet girişonwin güncel girişsahabet güncel girişpusulabet girişbetboo girişpusulabetslotbarmatadorbetbetboomatbet orijinalbetparkgrandpashabetsahabet güncel girişgrandpashabetCasibombetpuanslotbarbahiscombetpuangrandpashabet girişcasibomcasibomcasinoper girişcasinoperPusulabetcasibom girişdedebetromabettambetdinamobetsahabetbetwoonfenerbahçebetofficejojobetgrandpashabetgrandpashabetgrandpashabetlunabetgrandpashabetmarsbahis