Register your product to gain access to bonus material or receive a coupon.
TechnicalJava™Developing Scientific and Engineering ApplicationsGrant PalmerThe practical, example-rich guide to Java technical programming
If you want to use Java todevelop scientific or engineering programs, Technical Java is the Java guide you’vebeen searching for. Using real-life examples, expert scientific programmerGrant Palmer shows how to build powerful, versatile, and flexible software forvirtually any technical application. Whether you’re moving from FORTRAN,C, or C ++, or learning Java as your first language, Palmer covers all you needto know—
PRENTICE HALL
Profession TechnicalReference
Upper Saddle River, NJ 07458
www.phptr.com
ISBN: 0-13-101815-9
UPC: 076092022398
As an aid to your work with Technical Java: Applications for Science and Engineering, we are making available for download the code and supporting documents for all examples in the book (ZIP archive).
Download the Sample Chapter related to this title.
Preface.
Acknowledgments.
1. Introduction to Java.
A Brief History of Java. What Java Is. Installing Java on Your Machine. Compiling and Running Java Programs.
Program Structure. Basic Syntax. Variables. Subroutines, Functions, and Methods. Arrays. Dynamic Memory Allocation. Pointers. Exception Handling. Libraries. Built-in Math Functions. Input/Output Capability. GUIs and Web-Based Applications.
Program Structure. Basic Syntax. Java Classes vs. C Structs. Variables. Pointers. Functions and Methods. Arrays. Dynamic Memory Allocation. Exception Handling. C Libraries and the Java APIs. Strings. Built-in Math Functions. Basic Printing. Input/Output Capability. GUIs and Web-Based Applications.
Basic Syntax. Preprocessor Directives. Data Types. Pointers. Structures, Unions, Enumerations. Inheritance and Interfaces. Built-In Math Functions. Standard I/O. Strings. Memory Management.
Objects. Classes. Encapsulation. Inheritance. Polymorphism.
General Syntax and a Simple Java Program. Example: A Simple Java Program. Comments. Example: Using Comments. Operators. Arithmetic Operators. Assignment Operators. Increment/Decrement Operators. Relational Operators. Boolean Operators. Bitwise Operators. Miscellaneous Operators. Operator Precedence. Loops and Other Flow of Control Structures. if-else Statements. while Loops. do-while Loops. for Loops. switch Statements. Transfer of Control Statements. break Statements. continue Statements. return Statements. Basic Printing and Keyboard I/O.
Class Declaration Syntax. Access Privileges. Objects. Declaring Fields. Declaring Methods. Constructors. Static Initialization Blocks. Making Copies of Objects. Nested Classes. Static Nested Classes. Instance Nested Classes. Anonymous Inner Classes. Encapsulation. Inheritance. Inheritance and Access Modifiers. Inheritance and Method Arguments. Member Hiding and Member Overriding. The super Keyword. The this Keyword. Abstract Classes. Final Classes. The Garbage Collector.
Primitive and Reference Type Variables. Instance and Class Variables. Creating Variables. Naming Conventions and Restrictions. Access Modifiers. Accessing Variable Values. Final Variables. Transient and Volatile Variables. Casting. Variable Scope.
Declaring Methods. Naming Conventions. Access Modifiers. Instance Methods. Static Methods. The main() Method. Input Parameters. Passing Arguments to Methods. Abstract Methods. Final Methods. The native and synchronized Keywords. Method Chaining. Method Overloading. Method Overriding. The return Statement.
Differences Between Interfaces and Abstract Classes. Declaring an Interface. Interface Members. Implementing an Interface. Interfaces and Inheritance. Interface Instances as Input Parameters and Return Types.
Defining a Package. import Declarations. CLASSPATH Environment Variable. Packages and Access Control. JAR Files.
The Exception Class Hierarchy. try Statements. The try Statement. The catch Clause. The finally Clause. The throw and throws Keywords.
One-Dimensional Arrays. Two-Dimensional Arrays. Arrays of More than Two Dimensions. Initializing Array Elements. Accessing Array Elements. Arrays as Method Arguments and Return Types. Array Length. Collection Classes in the Java API.
Package Naming Conventions. The Core J2SE Libraries. java.io. java.lang. java.math. java.util. The GUI Libraries. java.awt. java.awt.event. javax.swing. javax.swing.border. javax.swing.event. javax.swing.table. javax.swing.text. javax.swing.tree.
Primitive Variable Wrapper Classes. Creating Primitive Variable Wrapper Class Objects. Converting a Wrapper Class Object to a Primitive Value. The parse() Methods. The String Class. Obtaining String Objects. Concatenating Strings. Other Important String Class Methods. Converting Primitive and Reference Types to Strings. Converting Strings to Primitive Values.
Math and StrictMath Classes. Mathematical Constants. Absolute Value Methods. Power and Square Root Methods. Transcendental Math Functions. Trigonometric Methods. Conversion Methods. Minimum and Maximum Methods. Rounding and Remainder Methods. Random Number Generator Methods. The java.math Package. Comparing the Built-in Math Capability of C, C++, Fortran, and Java. References.
Basic Plan of Attack. The Math2 Class. Logarithm Methods. Hyperbolic Trigonometric Methods. The Gamma Function. The Final Version of the Math2 Class. Compiling the Math2 Class. Using Math2 Class Methods. Comparing Java, C, and Fortran Values. References.
Defining the State and Behavior of a Gas Mixture. The General Class Hierarchy Structure. AbstractGas Class. PerfectGas Class. Air Class. RealGas Class. Species Class. N2 Class. N Class. NitrogenGas Class. Summary. References.
General Considerations. The EqnSolver Class. Test Case. Pivoting. Gauss-Jordan Elimination. Gaussian Elimination. Lower-Upper Decomposition. Matrix Inversion. Testing the EqnSolver Class Methods. Real Gas Viscosity Method.
Ordinary Differential Equations. The ODE Class. Initial Value Problems. Runge-Kutta Schemes. Example Problem: Damped Spring Motion. SpringODE class. Solving the Spring Motion ODE. Embedded Runge-Kutta Solvers. Other ODE Solution Techniques. Two-Point Boundary Problems. Shooting Methods. Example Problem: Compressible Boundary Layer. The CompressODE Class. Solving the Compressible Boundary Layer Equations. Other Two-Point Boundary Solution Techniques. Partial Differential Equations. References.
General Comments. Trapezoidal Algorithms. Simpson's Rule. Solving Improper Integrals. Gaussian Quadrature Methods. General Integral Types. Example: Thin Airfoil Theory. References.
The Fourier Transform. Discrete Fourier Transform. Analyzing Composite Signals. Sampling Theory. Spectral Leakage. Fast Fourier Transform.
Analyzing the Problem. Example: Least Squares Fit. Implementing the Generic Part. Implementing the Problem-Specific Part. Testing the Generic Class Library.
Least Squares Fit to a Polynomial Equation. The DataModeling Class. The Polynomial Class. Example Problem: Curve Fitting Specific Heat Data. Fitting to Nonpolynomial Equations. The Power Class. Other Data Modeling Techniques. References.
General Concepts. Byte Input Streams. InputStream Class. BufferedInputStream Class. ByteArrayInputStream Class. DataInputStream Class. FileInputStream Class. FilterInputStream Class. ObjectInputStream Class. Other InputStream Subclasses. Byte Output Streams. OutputStream Class. BufferedOutputStream Class. ByteArrayOutputStream Class. DataOutputStream Class. FileOutputStream Class. FilterOutputStream Class. ObjectOutputStream Class. PrintStream Class. Character Input Streams. Reader Class. BufferedReader Class. FileReader Class. InputStreamReader Class. Other Reader Subclasses. Character Output Streams. Writer Class. BufferedWriter Class. FileWriter Class. OutputStreamWriter Class. PrintWriter Class. Other Writer Subclasses. Test Case: An Atmosphere Modeling Tool. Getting Input from Command Line Arguments. Using the Standard I/O Streams. Reading and Writing to a File. Saving and Restoring Objects. The java.nio Packages. References.
The Java GUI Libraries. The AtmGUI Class. Choosing a Container. Selecting the GUI Components. Adding the Components to the Container. Event Handlers. Other GUI elements. The Final Form of the AtmGUI class.
Web-Based Application Basics. Java Servlets. Required Libraries and Tools. Example: A Web-Based Atmosphere Modeling Tool. HttpServlet Class. General Form of an HttpServlet Subclass. Extracting Input Parameters. Running Server-Based Applications. Sending Output Back to the Client Machine. The AtmServlet Class. Deploying the Web-Based Application.
This book was inspired by the following premise—Javais a great language for developing scientific and engineering applications.It’s more powerful and versatile than Fortan or C. It’s easier tolearn, less redundant, and less prone to error than C++. I have been ascientific programmer at a NASA research center for 18 years. You would thinksuch a place would be on the cutting edge of programming technology, but thatis not the case. Most of the technical programmers there still program in Fortranor C. The reason is largely one of inertia. Those languages are what they havealways used and they are comfortable with them. Some people have moved over toC++, and slowly but surely people are moving to Java as their technicalprogramming language of choice.
The book is designed to break through the inertia andmisconceptions that may have kept you from using Java for your scientific andengineering programming work. It will give you a good foundation in the basicsof Java and demonstrate how Java can be applied to solve a number ofmathematical analysis problems. The book will discuss migration issues fromother languages to Java and provide an introduction to developing GUI- orweb-based technical applications.
There are many features of Java that make it a good choicefor your technical programming work. For one thing, Java is an object-orientedlanguage. Because of this, it provides a structured framework for developingyour programs. When a code is written in an object-oriented manner, it becomeseasier to read and more modular. You can write programs that extend thecapabilities of existing programs. When an analysis procedure is written as anobject it can be easily incorporated into any number of different applications.
One of the design goals of the developers of Java was thatthe language be easy to learn and use. It borrows much of its basic syntax fromC and C++, but the developers of Java simplified the language by removingredundancies that exist in C and C++, as well as removing potentially dangerouselements—such as multiple inheritance—that were of marginal value.It is much easier to learn and apply Java, for example, than it is to learn andapply C or C++.
Another powerful feature is Java’s portability. Javaprograms are designed so that you can “compile once, run anywhere.”You can develop a scientific application on a UNIX workstation, transfer it toan Apple or Windows-based laptop, and the application will run without havingto recompile it. Java’s portability opens up the power of the Internet toyour technical programming work. You can easily develop your scientific orengineering applications as web-based programs.
There is a global support network for Java. You can getonline support and documentation from the Sun Microsystems website and manyother sources as well. There are Java User Groups (JUGs) pretty much anywhereyou live in just about every country. These groups are very useful for solvingproblems and discussing programming techniques and issues.
It also is easy to develop code in Java. You can leverageexisting classes and methods to develop new ones. In this book, we willdemonstrate how simple it is to create user-defined mathematical functions. Theobject-oriented structure of aJava makes the code easy to read. A program that is easy to read is easier tomaintain or modify.
Think of this book in four parts. The first includes ageneral introduction to Java and its development history. Following this arechapters that discuss migration issues from Fortan, C, or C++ to Java. You willfind that much of the basic syntax is the same between C, C++, and Java. Thereare some important differences, though, that these chapters will bring tolight.
The second part goes over the basic elements of the Javalanguage with an emphasis on topics pertinent to technical programming.Following a discussion of basic object-oriented programming concepts, there arechapters that discuss classes, methods, and variables. Interfaces, packages,and JAR files are also covered. There are chapters that discuss how Java treatsarrays and strings. Finally, there are chapters on the math capability ofJava—both the intrinsic functionality that comes with the Java API and a discussionof how to create user-defined math libraries.
Once we have a good understanding of the key elements of theJava language, we are ready to do some serious technical programming. The thirdpart of this book discusses how Java can be applied to such tasks as solvingsystems of equations, differential equations, integral functions, and Fouriertransforms. These chapters not only provide Java source code and real-lifemodel problems, but also delve into the theory behind the solution techniques.This section of the book also includes chapters on developing data curve fitsand generic class libraries.
The final part consists of three chapters covering importantfeatures you will probably make use of in your technical programming. Chapter25 discusses the input/output capability of Java. The Java API provides apowerful and versatile I/O functionality for reading and writing both byte andcharacter data. Java also gives you the ability to write GUI front ends to yourtechnical programs. An introduction to how this is done is provided in Chapter26. Another great feature of Java is that it gives you access to the power ofthe Internet. The final chapter of this book provides an introduction to howyou can turn a program into a web-based application using Java servlets.
This book will teach you the basic tools you will need tostart writing technical programs in Java, but it will not cover every possibleaspect of scientific or engineering programming. The book is not an exhaustivetreatise on solving differential equations, integral functions, or Fouriertransforms. Each of those topics is a book unto itself. This book will presentthe most commonly used techniques to solve those mathematical problems, butwon’t go into many specialized or super-advanced techniques.
The book also does not give a comprehensive description ofall of the classes, methods, interfaces, and fields from the Java API. The Javalibraries are enormous and a detailed look at even the Standard Editionlibraries would take many hundreds of pages. This book does cover some Java APIelements that are particularly relevant to technical programming. For adetailed look at the rest of the Java API, the reader is referred to the SunJava doc pages.
Download the Index
file related to this title.