PROG 10082 Lecture Notes - Lecture 4: Object-Oriented Programming, Mathematical Constant, Law And Justice
Document Summary
In the expressions examples slide, there"s 3 variables. mathematical methods functions are used to tell the computer how to calculate things, such as math. pow(x,y); Math is a class, and the method is coming from the class, so in thix example pow would be the power class. Math. sqrt would give us the second root of a number, as in squared. Math. pow(8, 1/3)--> make sure to write the 1/3 as 1. 0/3. Note that if you calculate the value of this expression, you get a negative value. There is no way to find the second root of a negative value. We are finding the sqrt of a negative number and java cant read it. type casting changes the value of a variable to another, and it is not recommended unless mandatory. 3, you cant change two variables at the same time-see slide saying example.