I am a new coder in Java and I'm encounter a tutorial about Palindrome that is giving me an error "The parameter 'num' should not be assigned in the highlighted line 16.
Can anyone take a look and offer some insight of what is causing this error?
The program runs correctly. but I am curious about this.
Thanks a lot! (See code below)
1 package javaTutorial;
2
3 public class IsPalindrome {
4
5 final static int num = 12321;
6
7 public static void main(String[] args) {
8 System.out.println(is_Palindrome(num));
9 }
10
11 public static int reverse(int num) {
12 int rev_num = 0;
13 while (num > 0) {
14 int r = num % 10;
15 rev_num = rev_num * 10 + r;
16 num /= 10; ************* ERROR
17 }
18 return rev_num;
19 }
20
21 public static boolean is_Palindrome(int num) {
22 if (num == reverse(num))
23 return true;
24 return false;
25 }
26 }