techhipbettruvabetnorabahisbahis forumutaraftarium24edusedusedusedusedusedusedueduseduedus Hollow Diamond Star Pattern Java Program | Patterns
Latest :

Hollow Diamond Star Pattern Java Program | Patterns

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

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

Using For Loop

1) The first outer for loop will display the half of the hollow diamond pattern, the 2nd outer for loop will display the remaining hollow diamond pattern.

2) The 1st outer for loop executes the set of statements until the condition i<n is false, if the condition is true the 1st inner loop will be executed until the condition is true, then it checks the if condition true it will display character “*”, otherwise else part will display space.

Next 2nd inner loop will be executed until the condition is false. For i=0 the 1st row of the hollow pattern completed. 1st for loop will display this pattern.

3) The 2nd outer for loop executes the statements until the condition is false. The 1st inner loop executes the statements until the condition is false. In this loop if “if” condition is true then it displays character “*” otherwise it displays space.

The 2nd inner loop executes the set of statements until the condition is false, in the 2nd inner loop if “if” condition true it display space else it displays character “*”. The 2nd outer loop will display this pattern.

Output:

Using While Loop

1) 1st outer while loop will execute the code until the condition is true. The 1st inner while loop executes the statements until the condition j<n.

In 1st inner while loop if j<n-i is true it will display character, else it displays space.

After 1st inner loop execution, the 2nd inner loop will execute the statements until the condition j<n is false. In the 2nd inner loop, if the condition is j<i  is true, it will display space else it will display character”*”.

2) The 2nd outer while loop will execute the statements until the condition i<=n is false. The 1st inner loop executes the statements until the condition j<n is false, in this loop if “if” condition is true then displays character “*” otherwise displays space.

After first inner loop execution, the 2nd inner loop will be executed until the condition j<n is false. In this 2nd inner loop if “if” condition is true j<n-i it will display space otherwise it will display character.

Output:

Using Do-While Loop

1) The 1st outer do-while loop will executes the code until the condition i<n is false. The 1st inner loop executes until j<n is false. In 1st inner loop if j<n-i is true it will display character “*” otherwise it will display space.

2) After 1st inner loop execution, the 2nd inner loop will be executed until the condition j<n is false, in this loop if the if condition j<i true it prints space otherwise prints character “*”.

3) The 2nd outer do-while loop will be executed until the condition i<=n. The 1st inner loop execute the statements until the condition is false. In this loop, if condition j<i true then prints character otherwise prints space.

4) After completion of 1st inner loop 2nd inner loop will be executed until the condition j<i is false. The if condition j<n-i true then prints space otherwise prints the character.

Output:

For More:

List of Java Programs – More than 500+ Java Programs

techhipbettruvabetnorabahisbahis forumutaraftarium24eduedueduedusedusedusedusedueduedus
x

Check Also

Rhombus Star Pattern Program In Java – Patterns

Java program to print Rhombus star pattern program. We have written the below print/draw Rhombus ...

betwoonhacklink satın aljojobet girişakcebet uyeliksupertotobet1xbet girişmelbet girişbetwinnerpinup uyelikbtcbahis girişmostbet girişbetwinner girişxslotskyloft uyelikmegapari uyeliktipobetgrandpashabetgrandpashabetmariobett.mebetandreasenbetcasivalmisbahismyhitbetonbahistipobetbahsinevavepasgolgrandpashabetmarsbahispusulabetcasibomcasibom girişcasibom güncel girişcasibomcasibom girişdeneme bonusu veren sitelerhttps://mobilebarhawaii.com/ballettea tropazjokerbet güncel girişmatadorbetbets10betturkeycasibomkingroyalbets10 girişbets10bets10 girişmaldives casinohacklinkgrandpashabetbetmatik girişmelbetmostbetmegapari üyelikmatadorbetartemisbetJojobet girişcasibompinco girisonwinonwin girişcasibom güncel girişselcuksportshdcasibomcasibomatakoy escortatakoy escortsisli escortgalatabahisliste paris sportifjeux casino gratuit avec bonusSimsinos CasinojojobetCashimashi AvisWunderWinsparier sur les cornersGamdomCasibommadridbet girişmatbetpinbahisemiratesbettrbetcasibomcratosroyalbetcasinokaliprensbetmostbet guncel girisbetandyou guncel girisromabet guncel giris7slots guncel girisbizbet guncel girisrocksroyalbetkazandradeneme bonusu veren sitelergrandpashabetonwinprincessbetbetkanyonpinup yeni girismatadorbet yeni girisroketbet yeni girisskyloft yeni girismegapari yeni girissavoybettingcasinomhubligobetmavibetenobahisJojobetjetbetcasinomaxikingroyalsahabethttps://www.escortbayanlariz.net/beylikdüzü escortfikstürbetmisliwinbetwoonjojobetsahabettarafbetpusulabetcoinbarmariobetmilanobetlunabetcasibomcasibom girişbetsmovebetnanobetparkvevobahisKonak escortimajbetbetnanovevobahismarsbahismarsbahisbetebetcasibombetciobakırköy escortcasinometropolmatbetsüperbetin güncel girişjojobetpusulabetholiganbetmarsbahisjojobet girişcasibomextrabetcasibomdeneme bonusu veren sitelerholiganbetmatbetbetturkeyhalkali escortbetwooncasibom güncel girişsahabetartemisbetbetparkmavibetjojobetbets10dumanbetdumanbetfixbetkralbetkulisbetsekabet girişholiganbet güncel girişjojobet güncel girişartemisbetimajbetcasibom girişjojobetpadişahbetbets10 girişbets10 girişonwinselçuksportsSekabetholiganbethttps://www.gvscolombia.com/casino sitelerimatbet güncel girişartemisbetimajbet giriş1xbet1xbetcasibomgrandpashabetredwincasibomankara escort bayanxslotcasibomgrandpashabetcasivalmarsbahispusulabetbetofficeJojobet girişmaldives betcasibom girişCasibommarsbahiscasibom girişgrandpashabet girişbahiscasinojokerbet güncel girişcasibomcasibom girişcasibomcasibomtaraftarium24holiganbetholiganbetholiganbetjojobetcasibomGrandpashabet güncel girişcasibomjojobetonwinextrabetbetwoonextrabet girişmatbetbetciomarsbahisgrandpashabetTipobetbetistPusulabetcasibomesenyurt anal escortbetcioSekabetcasibomvevobahiscasibom girişcasino sitelerigrandpashabetİstanbul Escortcasinomaxihttps://www.gvscolombia.com/betebetgrandpashabetdeneme bonusu veren sitelerfixbetholiganbetmarsbahis girişstarzbetjojobetjojobet girişmrbahismrbahisCasibom girişsahabetjojobetjojobet girişİmajbetjojobet güncel girişkucukcekmece escortmarsbahissahabetsekabetrestbetpinbahisonwinmobilbahismeritbetmavibetmatbetmatadorbetmaltcasinobets10meritkingizmir escorttexas sweepstakesflorida sweepstakessweepstakes sportsbooksweepslotscasibomcasibom girişbankobet girişGrandpashabetmobilbahisbetciorestbetcasibomgrandpashabetmatadorbetmaltcasinoholiganbetmarsbahisonwinsahabetsekabetmatbetimajbetmarsbahis güncel girişbetsattuzla escort bayancanlı bahisimajbetstarzbetmobil ödeme bozdurmajojobetcasibombetcioCASİBOMcasibomcasibom girişcasibom güncel girişjojobetcasibomcasibom girişevde paketleme işicasibom giriştempobetkalebetsafirbetngsbahispusulabetcoinbartarafbettempobetmarsbahisperabetstarzbetpusulabet