Sunday, 18 August 2013

Write a java program to print the following patern:

This patern is:
D
DU
DUM
DUMK
DUMKA
DUMKAL
----------------------
test.java
----------------------
class test
{
public static void main(String arg[]){
String str="DUMKAL";
int len,i;
len=str.length();
for(i=1; i<=len; i++){
System.out.println(str.substring(0,i));
}
}
}


Output:
-----------------------
D
DU
DUM
DUMK
DUMKA
DUMKAL

No comments:

Post a Comment