i have to print this
********
*** ***
** **
* *
** **
*** ***
********
my code is

class one
{
 public static void main(String args[])
 {
  String s1="*";int i,j;
  for(i=4;i>0;i--)
  {
     for(j=0;j<i;j++)
     {
     System.out.print(s1);
     }
  for(int k=0;k<8;k=k+2)
  {
    for(int m=0;m<k;m++)
    System.out.print(" ");
  }
  for(int n=4;n>0;i--)
  { 
   for(int l=0;l<n;l++)
   {
    System.out.print(s1);
   }
  }
  System.out.println();
  }
 }
}
anupam_smart commented: Good Question... :) +5

i have to print this
********
*** ***
** **
* *
** **
*** ***
********
my code is

class one
{
 public static void main(String args[])
 {
  String s1="*";int i,j;
  for(i=4;i>0;i--)
  {
     for(j=0;j<i;j++)
     {
     System.out.print(s1);
     }
  for(int k=0;k<8;k=k+2)
  {
    for(int m=0;m<k;m++)
    System.out.print(" ");
  }
  for(int n=4;n>0;i--)
  { 
   for(int l=0;l<n;l++)
   {
    System.out.print(s1);
   }
  }
  System.out.println();
  }
 }
}

Put your pattern in code tags too. Spacing is stripped out otherwise. What's the question?

********
***  ***
**    **
*      *
**    **
***  ***
*******[B]*[/B]

Line 17 - infinite loop caused by i--

for (int n = 4; n > 0; n--) {

i have to get the star pattern as given

********
***  ***
**    **
*      *
**    **
***  ***
********

i am not so clear with the for loop in this case and working with blank spaces.

i have to get the star pattern as given

********
***  ***
**    **
*      *
**    **
***  ***
********

i am not so clear with the for loop in this case and working with blank spaces.

try this one... i haven't made it general for any number of lines (left that part for u if u need to implement it)... just tried for the one you've showed up here.... Here it is... :)

class one
{
 public static void main(String args[])
 {
  String s1="*";
  int i,j,l=8,x=8,y=8;
  for(int n=0;n<7;n++)
  {  	
  	for(i=l/2;i>0;i--)
  	{
     	System.out.print(s1);
   	}
	for(int k=0;k<x-l;k++)
	{
	   		System.out.print(" ");
	}
	for(i=l/2;i>0;i--)
  	{  	 
     	System.out.print(s1);     	 
	}
	System.out.println(l+" "+x);
	if(y>2)
	{
		l-=2;
		y=l;
	}		
	else
		l+=2;
  }
 }
}

Hope it helps you... Mail me if you wish a friendship with me... LOL (m serious) :$:cool::D

mr.smart thanks..ya i like friends

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.