0

whats wrong with the code

public class MyProgram{ public static void PalindromeNumber(int n){ int sum = 0; int b = n; while(n>0){ int a = n%10; sum = (sum*10) + a; n = n/10; } if(sum == b){ System.out.println(b+" is palindrome number"); } else{ System.out.println(b+" is not palindrome number"); } public static void main(String[] args){ PalindromeNumber(393); } } } when i call the method PalindromeNumber from another class it works but not within its own class why

14th Aug 2019, 5:38 AM
stephen haokip
stephen haokip - avatar
1 Réponse
+ 1
methods P..() ends after main(), it is wrong, correct it this way: } // add bracket here public static void main(String[] args) { PalindromeNumber(393); } // } delete this bracket }
14th Aug 2019, 8:53 AM
zemiak