Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+18 votes

Do we have to put int in front of math class method every time we put in the command line ?
For example, System.out.print((int) Math.
Thank you.

asked in CSC211_Winter2018 by (1 point)
0

I agree with her

2 Answers

+11 votes

I don't think we need to put int every time we put the command line. (int) only helps you to make the result of the math class method become an integer so I think the decision is based on the result we want and the math class method. If the math class method creates a double result and we need an integer, we need (int) because we need to transfer from double to integer. But if the math class method creates an integer result and we need an integer, we don't need (int) because the result is already an integer.

answered by (1 point)
+5 votes

I agree with her

answered by (1 point)
...