楼主: ReneeBK
1780 13

Technical Java™: Developing Scientific and Engineering Applications [推广有奖]

11
ReneeBK 发表于 2015-7-26 07:14:38
Built-in Math Functions

Both the Java and C libraries provide built-in functions to compute absolute value, power, square root, transcendental, trigonometric, rounding, and other mathematical functions. The built-in math capability of the two languages is quite similar, even some of the function/method names are identical. C has some built-in functions that Java does not—the hyperbolic trigonometric and base 10 logarithm functions, for example. Java has some math methods that C does not, the toRadians(), min(), and max() methods for instance. Java takes advantage of method overloading to streamline its math methods. While C has to define three absolute value methods, one for each of three data types, Java only has to define one absolute value method that can take integer or floating point arguments.


12
ReneeBK 发表于 2015-7-26 07:16:01
Basic Printing

Basic printing in C is performed using the printf()and fprintf()functions. These functions print a string to either the console or to a file using format specifiers (%lf, %s, etc.) to convert variable values to strings. The basic print functions in Java are the print() and println() methods. Every Java object has a handy method called toString()that returns a string representation of it.


13
ReneeBK 发表于 2015-7-26 07:17:45
Input/Output Capability

The I/O functionality in C is rudimentary at best. You spend a lot of time using nonintuitive functions such as scanf(), sscanf(), and gets(). Some of the functions will read a newline character at the end of a line and some will not. These functions also tend to be quite format-specific. You have to specify exactly what variable type is to be read and returned from these functions. It is easy to run into conversion problems between, say, a float and a double. Reading and parsing an input file can be an intricate and error-prone process.

Java has a much improved I/O functionality over that offered by C. Like C, Java uses a stream-based I/O system. A data stream is simply an abstraction that represents a data connection between a source and a destination. Java provides a wide array of specialized I/O stream classes in two general categories. Character streams are designed to read and write character data. The characters can be read in one at a time or an entire line of data can be read in as a String. Byte streams are intended to read and write binary data. The data can be read in one byte at a time or an entire buffer of byte data can be read.


14
ReneeBK 发表于 2015-7-26 07:19:06
GUIs and Web-Based Applications

The standard C libraries do not contain any GUI or web-based application capability. Java has entire libraries devoted to GUI development. You can also develop your own custom GUI components. With Java you can write a sophisticated GUI front-end for your scientific and engineering application without having to learn or use another programming language. A brief introduction to Java GUI development is provided in Chapter 26. Java also allows you to develop powerful web-based applications with an extraordinarily powerful set of facilities such as servlets, JavaServer Pages (JSP), and Enterprise JavaBeans (EJBs). An introduction to web-based applications can be found in Chapter 27.


您需要登录后才可以回帖 登录 | 我要注册

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2025-12-29 09:29