butterfly pattern program in java
Java
import java.util.Scanner;
public class ButterFly {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter n value");
int n=sc.nextInt();
int sp=2*n-1,st=0;
for(int i=1;i<=2*n-1;i++){
if(i<=n){
sp=sp-2;
st++;
}
else{
sp=sp+2;
st--;
}
for(int j=1;j<=st;j++){
System.out.print("*");
}
for(int k=1;k<=sp;k++){
System.out.print(" ");
}
for(int l=1;l<=st;l++){
if(l!=n)
System.out.print("*");
}
System.out.println();
}
}
}
Also in Java:
- Title
- splitting using regex java
- Category
- Java
- Title
- how lock horizontal orientation android
- Category
- Java
- Title
- how to input in java
- Category
- Java
- Title
- int java
- Category
- Java
- Title
- how to print an array in java
- Category
- Java
- Title
- random boolean java
- Category
- Java
- Title
- abstraction in java
- Category
- Java
- Title
- java get environment variables
- Category
- Java
- Title
- create instance object java
- Category
- Java
- Title
- print values of bst java
- Category
- Java
- Title
- java printf tab
- Category
- Java
- Title
- how to check the end of a string java
- Category
- Java
- Title
- connecting to h2 database from java
- Category
- Java
- Title
- java enum
- Category
- Java
- Title
- reverse linked list in java to get both head and tail
- Category
- Java
- Title
- processing library cassette
- Category
- Java
- Title
- java read file bufferedreader
- Category
- Java
- Title
- python vs java
- Category
- Java
- Title
- long to int java 8
- Category
- Java
- Title
- Java array multidimensional hashcode
- Category
- Java
- Title
- how to add an image to a gui in java windowbuilder
- Category
- Java
- Title
- java newinstance alternative
- Category
- Java
- Title
- iterate map in java 8 using stream
- Category
- Java
- Title
- Removing DOM nodes when traversing a NodeList
- Category
- Java
- Title
- java new string with values
- Category
- Java
- Title
- java date time
- Category
- Java
- Title
- how to loop trough an object java script
- Category
- Java
- Title
- expression régulière seulement un espace java
- Category
- Java
- Title
- java string to character stream
- Category
- Java
- Title
- Write a JAVA method that expands a given binomial (ax + by)n, where integers a, b, n are user inputs. For example, if a = 2, b = -12, n = 4 are entered the method should print or return
- Category
- Java
- Title
- validate isbn number java
- Category
- Java
- Title
- how to add objects in array java
- Category
- Java
- Title
- arrays.fill java
- Category
- Java
- Title
- javafx detect collision
- Category
- Java
- Title
- how to convert char to uppercase java
- Category
- Java
- Title
- transformez integer en string
- Category
- Java
- Title
- java int
- Category
- Java
- Title
- how to iterate list in java selenium
- Category
- Java
- Title
- import scanner
- Category
- Java
- Title
- java define main function
- Category
- Java
- Title
- java hashmap get value
- Category
- Java
- Title
- how to add a keylistener to a jframe
- Category
- Java
- Title
- how to create a JFrame in java
- Category
- Java
- Title
- java swing timer sleep
- Category
- Java
- Title
- start thread java
- Category
- Java
- Title
- partial view tiles spring
- Category
- Java
- Title
- java comments
- Category
- Java
- Title
- java identifier expected
- Category
- Java
- Title
- abstract class in java
- Category
- Java
- Title
- how to substring in java
- Category
- Java
- Title
- java variable declaration
- Category
- Java
- Title
- queue implementation in java using arraylist
- Category
- Java
- Title
- boolean parse jtextfield
- Category
- Java
- Title
- java xml element get attribute value
- Category
- Java
- Title
- declare String in java
- Category
- Java
- Title
- java get icon for file type
- Category
- Java
- Title
- editer un label java
- Category
- Java
- Title
- convert string to localdatetime
- Category
- Java
- Title
- check if optional is empty java
- Category
- Java
- Title
- java get current date without time
- Category
- Java
- Title
- array in java stack overflow
- Category
- Java
- Title
- encode file to utf-8 in java
- Category
- Java
- Title
- convert hashset to int array java
- Category
- Java
- Title
- int to binary java
- Category
- Java
- Title
- get number of items in arraylist java
- Category
- Java
- Title
- number of matches regex java
- Category
- Java
- Title
- string contains java
- Category
- Java
- Title
- sum of arraylist java 8
- Category
- Java
- Title
- java.sql.SQLException: Before start of result set
- Category
- Java
- Title
- java instantiate collection with values
- Category
- Java
- Title
- java script to detect and launch all browsers
- Category
- Java
- Title
- how get started with LWJGL 3
- Category
- Java
- Title
- java boolean even number
- Category
- Java
- Title
- java observable to observer
- Category
- Java
- Title
- binary search java
- Category
- Java
- Title
- array rotation program in java
- Category
- Java
- Title
- leap year checker java
- Category
- Java
- Title
- if statement java
- Category
- Java
- Title
- replace all punctuation in string java
- Category
- Java
- Title
- generate all prime number less than n java (fastest method)
- Category
- Java
- Title
- android switch on change
- Category
- Java
- Title
- java array out of bounds
- Category
- Java
- Title
- foreach java
- Category
- Java
- Title
- java 8 validate based on pair of strings
- Category
- Java
- Title
- java switch display panel
- Category
- Java
- Title
- FileNotFoundException: properties/fortunes.txt (No such file or directory)
- Category
- Java
- Title
- java switch case
- Category
- Java
- Title
- how to change all the text in a textArea java at once
- Category
- Java
- Title
- the type javax.servlet.ServletException cannot be resolved. It is indirectly referenced from required .class files
- Category
- Java
- Title
- how to get the checkbox checked value in javafx
- Category
- Java
- Title
- import java.util.hashset
- Category
- Java
- Title
- output statement java
- Category
- Java
- Title
- java get command line output
- Category
- Java
- Title
- Compare integers java sort
- Category
- Java
- Title
- NumSelfDivisors java
- Category
- Java
- Title
- bufferedwriter doesn't write to file
- Category
- Java
- Title
- throwing exceptions java
- Category
- Java
- Title
- gson parse json
- Category
- Java
- Title
- how to check if in array java
- Category
- Java
- Title
- get drawable with string android java
- Category
- Java