+ 1
Friends i want to print digits in reverse order. Like 12345 to 54321. Please tell me what's wrong in code.
class reverse{ public static void main(String[] args){ int digits[] = {1,2,3,4,5}; int i = digits.length; while(i>0){ System.out.println(digits[i-1]); --i;} }}
16 odpowiedzi
+ 6
Change :
i < 0
By :
i > 0
+ 3
If you want :
54321
Instead of :
5
4
3
2
1
Change :
println
By :
print
+ 3
thanks my friend for help
+ 2
the above code is not working
+ 2
ok
+ 2
Java != JS
+ 1
@Sahil, do not listen to @Talluri, his answer is the exact same code you post at the beginning, which obviously did not work
+ 1
/* for php this the code you need but if you are trying what iam thinking about..its not gonna work but its always good to practice and try */
$amount = str_replace("0.0001", "9.999", " 0.0001");
+ 1
@UNlimitedLearN, he wants java help, not JS or php ^^
0
i tried it with php str_replace but its not working....if you are trying what iam trying too :-) but keep trying anyway,persistence is the engine of knowledge
0
class reverse{
public static void main(String[] args){
int digits[] = {1,2,3,4,5};
int i = digits.length;
while(i<0){
System.out.println(digits[i-1]);
--i;}
}}
//try this
0
it show "no output" always
0
/** simple reverse code bro enjoy **/
var amount = ['1', '2', '3', '4', '5'];
var reversed = amount.reverse();
console.log(reversed);
0
/** this best code you can do but dont know why on sololearn simulator it tells illegal return **/
function reverseString(str) {
var splitString = "0.001".split("");
var reverseArray = ["0.", "0", "0", "1"].reverse();
var joinArray = ["1.", "0", "0", "0"].join("");
}
return joinArray;
0
whatever you said bro,i hate java js jquery anything related to java i hate it lol iam php & pyhon jeek,i thought he's searching reversing dicegames like bitsler,are you trying too?