+ 4
Please tell the error in my program
i have to make a pattern like this 12345 12341 12342 12343 12345 and i am getting problem in my program where the last line is printing the wrong statement.
6 Answers
+ 14
Post your code here:-(
+ 12
If possible, please provide a Minimal, Complete, and Verifiable code @ Code Playground so we can help you to take a look on the code. đ
+ 6
The Alchemist, try this, tested in Code Playground:
public class Program
{
public static void main(String[] args)
{
String s = "12345";
int x, l = s.length();
System.out.println(s);
for(x = 0; x < l; x++)
{
if(x != 3)
System.out.println(s.substring(0, 4) + s.substring(x, x + 1));
}
}
}
Hth, cmiiw
+ 4
sorry ipang but 12344 is not to be printed
+ 4
@The Alchemist, sorry skipped that one : )
Code updated, please check again : )
+ 2
here is the code
https://code.sololearn.com/c00uxP79Z6Eb/?ref=app