How to print the following pattern in java?

How to print the following pattern in java?

he he is he is going he is going in

View Answers

March 29, 2012 at 4:45 PM

import java.io.*; 
class StringPattern 
{ 
    public static void main(String[] args) throws IOException{ 

        String st="he is going in";
        String str[]=st.split(" ");

        for(byte i=0;i<str.length;i++) 
        { 
            System.out.println(); 

            for(byte j=0;j<=i;j++) 
                System.out.print(str[j]+" "); 
        } 
    }
}









Related Tutorials/Questions & Answers:
Advertisements