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

Suppose you have an int variable called number. What Java expression produces the last digit of the number (the 1s place)?SolutionHi, we can do it in two ways,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site