Posts

Showing posts from June 2, 2014

How to return Multiple lines String in Java

We can return a multiple linesstring 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;


}
}