0

Program to print the following pattern in java

h he hel hell hello I tried the following code ``` public class Pyramid{ public static void main(String[] args){ int i,j; String W="hello"; for(i=1;i<=4;i++) { for(j=1;j<=W.length();j++){ System.out.print(W); } System.out.print(j); } System.out.println(); } }

22nd Dec 2019, 11:27 AM
Alfred Monir
Alfred Monir - avatar
11 Antworten
+ 5
Param Siddharth Yes I know
24th Dec 2019, 7:12 AM
A͢J
A͢J - avatar
+ 3
Alfred Monir Hugo Check again and try to do self Edited Pattern 2 in reverse order
22nd Dec 2019, 12:52 PM
A͢J
A͢J - avatar
22nd Dec 2019, 12:48 PM
Alfred Monir
Alfred Monir - avatar
+ 2
🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ! Ok i am trying and Thank you for your help
22nd Dec 2019, 12:55 PM
Alfred Monir
Alfred Monir - avatar
22nd Dec 2019, 4:49 PM
Michal
Michal - avatar
24th Dec 2019, 6:58 AM
Param Siddharth
Param Siddharth - avatar
+ 1
🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ! I tried this code after your help and got the answer- public class Program { public static void main(String[] args) { int i,j; String W="hello"; for(i=0;i<=W.length();i++) { for(j=0;j<i;j++){ System.out.print(W.charAt(j)); } System.out.println(); } } } By the way Thankyou everyone for answering and helping me out.
22nd Dec 2019, 1:22 PM
Alfred Monir
Alfred Monir - avatar
+ 1
Michal Thank you for the answer
22nd Dec 2019, 4:59 PM
Alfred Monir
Alfred Monir - avatar
+ 1
🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ!, "Methods or library not allowed..." You guys both used methods from String class so what is the difference?
24th Dec 2019, 7:21 AM
Michal
Michal - avatar
+ 1
Michal I deleted my answer.😂😂
24th Dec 2019, 7:25 AM
A͢J
A͢J - avatar