|
The previous article in this series ("Variables Defined") touched briefly on the concept of data types. In this article, you'll look at data types a little more in depth and examine why they are important to programmers. Sometimes you're so familiar with a class you stop paying attention to it. If you could write the documentation for java.lang.Foo, and Eclipse will helpfully autocomplete the functions for you, why would you ever need to read its Javadoc? Such was my experience with java.lang.Math, a class I thought I knew really, really well. Imagine my surprise, then, when I recently happened to be reading its Javadoc for possibly the first time in half a decade and realized that the class had almost doubled in size with 20 new methods I'd never heard of. Obviously it was time to take another look. In the previous chapter you learned that computers think in terms of 1s and 0s, and that you can use those 1s and 0s to represent numbers, characters, and booleans. Then you learned that through Java you could create meaningful names that refer to regions of memory using variables. The next step is to take those variables and do something meaningful with them. In this chapter, you will address all the mathematical operations you can perform in Java on primitive data types. If you try to find a closed-form analytical solution to the above equation, do not bother; there is none. You cannot apply traditional methods such as integrating-by-parts or integrating-by-substitution to solve for a closed form solution. Numerical computation can solve and compute the answer to the above equation or any type of model problem by using some well-known numerical analysis techniques such as Euler, Runge-Kutta-Fehlberg, multistep, Adams-Moulton, and so forth. The only mathematical operations that require solving for the solution are addition, subtraction, multiplication, division, and numeric comparisons. Because these simple operations are exactly what a computer does, numerical computation is best achieved using it. A numerical solution to a problem model is always numerical, while analytical methods produce a result in terms of mathematical functions. Analysis of computer errors and all sources of error in numerical computation are critical to the accuracy of calculation. Numerical computation can be done in any computer language, but there are traditional ones that are in favour with the community of software developers. Fortran has been the cornerstone choice from the early days of computers; Pascal, C, C++, and MatLab have also established themselves in numerical computing. Java has risen amongst the academic institutions, government research institutes, industry, and the scientific communities to be a preferred language for developing numerical-based software. On the other hand, the Smalltalk environment and its loose typing allow Smalltalk programmers to be far more productive. The need for typing has been addressed even for Smalltalk in systems like Strong-talk [Bracha 93]. Undoubtedly, the differences between Smalltalk and C++ are too large for any serious defection of programmers from any camp. However, I have personally met enough people that were very religious about their own language (be it Smalltalk or C++) and who showed minimal or no resistance in picking up Java. My own favorite definition of the Java language is that it is "Smalltalk with a C++ syntax." |
| w__ww___._j_a___v__a___2_s___.__co___m | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |