Suppose you have an int variable called number What Java exp
Suppose you have an int variable called number. What Java expression produces the last digit of the number (the 1s place)?
Solution
Hi,
we can do it in two ways,
1) first one is we can just use % with 10 and it will give the remainder and the would be the last digit of the number
2) the second methond is to convert the number to string and accesing the array number or to use charAt function of java string function
Thank you
Please comment below for any doubts

