We can return a multiple lines string in java by using "\n"
Example:
import java.io.*;
public class pack1
{
public static String make(int n)
{
String s="";
int i,j,k;
for(i=0; i<n;i++)
{
for(k=n-i-1;k>=0;k--)
s=s+" ";
for(j=1;j<=i*2+1;j++)
s=s+"*";
s+="\n";
}
return s;
}
}
Example:
import java.io.*;
public class pack1
{
public static String make(int n)
{
String s="";
int i,j,k;
for(i=0; i<n;i++)
{
for(k=n-i-1;k>=0;k--)
s=s+" ";
for(j=1;j<=i*2+1;j++)
s=s+"*";
s+="\n";
}
return s;
}
}
Comments