You are previewing Technical Java™: Developing Scientific and Engineering Applications.
O'Reilly logo
Technical Java™: Developing Scientific and Engineering Applications

Book Description

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—

  • Java, FORTRAN, C, and C ++, similarities, differences, and migration issues

  • Java 1.4 syntax, objects, classes, methods, interfaces, variables, arrays, exceptions, packages, I/O, and more

  • Working with java.math and creating your own math functions—including detailed trigonometric and transcendental examples

  • Data modeling, in depth: class hierarchies, generic class libraries, least-squares fit, fitting to non-polynomial equations, and more

  • Solving differential equations and systems of equations, including Gauss-Jordan and Gaussian elimination, lower-upper decomposition, and matrix inversion

  • Solving integral equations with both proper and improper integrals

  • Working with Fourier transforms (DFT and FFT)

  • Building Web and GUI-based technical applications with Swing/AWT and servlets

  • PRENTICE HALL

    Profession TechnicalReference

    Upper Saddle River, NJ 07458

    www.phptr.com

    ISBN: 0-13-101815-9

    UPC: 076092022398

    Table of Contents

    1. Copyright
      1. Dedication
    2. About the FTP Site
    3. Preface
      1. Why Is Java a Good Technical Programming Language?
      2. The Structure of This Book
      3. What This Book Is Not
    4. Acknowledgments
    5. 1. Introduction To Java
      1. A Brief History of Java
        1. Humble Beginnings
        2. Java 1.0
        3. Java 1.1
        4. Java 1.2
        5. Java 1.3 and Java 1.4
        6. The Future
      2. What Java is
        1. Simple and Familiar
        2. Object Oriented
        3. Interpreted and Platform Neutral
        4. Robust
        5. Secure
        6. Multithreaded
        7. Versatile and Expandable
      3. Installing Java on Your Machine
      4. Compiling and Running Java Programs
    6. 2. Moving from Fortran to Java
      1. Program Structure
      2. Basic Syntax
      3. Variables
      4. Subroutines, Functions, and Methods
      5. Arrays
      6. Dynamic Memory Allocation
      7. Pointers
      8. Exception Handling
      9. Libraries
      10. Built-in Math Functions
      11. Input/Output Capability
      12. GUIs and Web-Based Applications
    7. 3. Moving from C to Java
      1. Program Structure
      2. Basic Syntax
      3. Java Classes vs. C Structs
      4. Variables
      5. Pointers
      6. Functions and Methods
      7. Arrays
      8. Dynamic Memory Allocation
      9. Exception Handling
      10. C Libraries and the Java APIs
      11. Strings
      12. Built-in Math Functions
      13. Basic Printing
      14. Input/Output Capability
      15. GUIs and Web-Based Applications
    8. 4. Moving from C++ to Java
      1. Basic Syntax
      2. Preprocessor Directives
      3. Data Types
      4. Pointers
      5. Structures, Unions, Enumerations
      6. Inheritance and Interfaces
      7. Built-In Math Functions
      8. Standard I/O
      9. Strings
      10. Memory Management
    9. 5. An Overview of Object-Oriented Programming Concepts
      1. Objects
      2. Classes
      3. Encapsulation
      4. Inheritance
      5. Polymorphism
    10. 6. Basic Syntax
      1. General Syntax and a Simple Java Program
        1. Example: A Simple Java Program
      2. Comments
        1. Example: Using Comments
      3. Operators
        1. Arithmetic Operators
          1. Example: Using Arithmetic Operators
        2. Assignment Operators
          1. Example: Using Assignment Operators
        3. Increment/Decrement Operators
          1. Example: Using the Increment Operator
        4. Relational Operators
          1. Example: Using Relational Operators
        5. Boolean Operators
          1. Example: Using Boolean Operators
        6. Bitwise Operators
          1. Example: Using Bitwise Operators
        7. Miscellaneous Operators
          1. Example: Miscellaneous Operators
        8. Operator Precedence
          1. Example: Operator Precedence Example
      4. Loops and Other Flow of Control Structures
        1. if—else Statements
          1. Example: Using if-else Statements
        2. while Loops
          1. Example: Using while Loops
        3. do-while Loops
          1. Example: Using do-while Loops
        4. for Loops
          1. Example: Using for Loops
        5. switch Statements
          1. Example: Using a switch Statement
      5. Transfer of Control Statements
        1. break Statements
          1. Example: Breaking Out of an Outer Loop
        2. continue Statements
        3. return Statements
      6. Basic Printing and Keyboard I/O
        1. Example: Reading Console Input
    11. 7. Classes
      1. Class Declaration Syntax
      2. Access Privileges
      3. Objects
        1. Example: Creating Objects
      4. Declaring Fields
        1. Example: Defining a Simple Class
      5. Declaring Methods
        1. Example: Adding Methods to a Class
      6. Constructors
        1. Example: Adding Constructors to a Class
      7. Static Initialization Blocks
        1. Example: Using Static Initialization Blocks
      8. Making Copies of Objects
        1. Example: Copying Objects
      9. Nested Classes
        1. Static Nested Classes
        2. Instance Nested Classes
          1. Example: Using an Inner Class as an Event Listener
        3. Anonymous Inner Classes
          1. Example: Using an Anonymous Inner Class
      10. Encapsulation
      11. Inheritance
        1. Example: Inheritance Basics
        2. Inheritance and Access Modifiers
        3. Inheritance and Method Arguments
          1. Example: Sending a Subclass Object to a Method
        4. Member Hiding and Member Overriding
      12. The super Keyword
        1. Example: Using the super Keyword
      13. The this Keyword
        1. Example: Using the this Keyword
      14. Abstract Classes
        1. Example: Using Abstract Classes
      15. Final Classes
      16. The Garbage Collector
    12. 8. Variables
      1. Primitive and Reference Type Variables
        1. Example: Using Primitive and Reference Variables
      2. Instance and Class Variables
        1. Example: Using Instance and Class Variables
      3. Creating Variables
        1. Example: Declaring Variables
        2. Example: Initializing Variables
      4. Naming Conventions and Restrictions
      5. Access Modifiers
      6. Accessing Variable Values
        1. Example: Accessing Variables
      7. Final Variables
        1. Example: Using Final Variables
      8. Transient and Volatile Variables
      9. Casting
        1. Example: Casting
      10. Variable Scope
        1. Example: Dealing with Scope
    13. 9. Methods
      1. Declaring Methods
        1. Example: Declaring Methods
      2. Naming Conventions
      3. Access Modifiers
        1. Example: Method Access
      4. Instance Methods
        1. Example: Writing Instance Methods
      5. Static Methods
        1. Example: Defining Static Methods
      6. The main() Method
        1. Example: Using Command Line Arguments in main()
      7. Input Parameters
        1. Passing Arguments to Methods
          1. Example: Primitive and Reference Type Input Arguments
      8. Abstract Methods
        1. Example: Abstract Methods
      9. Final Methods
      10. The native and synchronized Keywords
      11. Method Chaining
        1. Example: Using Method Chaining
      12. Method Overloading
        1. Example: Overloading Methods
      13. Method Overriding
        1. Example: Overriding Methods
      14. The return Statement
        1. Example: Using return Statements
    14. 10. Interfaces
      1. Differences Between Interfaces and Abstract Classes
      2. Declaring an Interface
        1. Example: Declaring Interfaces
      3. Interface Members
        1. Example: Defining Interface Members
      4. Implementing an Interface
        1. Example: Implementing an Interface
      5. Interfaces and Inheritance
      6. Interface Instances as Input Parameters and Return Types
        1. Example: Using Interfaces to Reference Disparate Classes
    15. 11. Packages and JAR Files
      1. Defining a Package
        1. Example: Including Classes in Packages
      2. import Declarations
        1. Example: Importing a User-Defined Package
      3. CLASSPATH Environment Variable
        1. Example: Using CLASSPATH to Locate .class Files
      4. Packages and Access Control
      5. JAR Files
        1. Example: Creating a JAR File
        2. Example: Viewing the Contents of a JAR File
        3. Example: Extracting Files from a JAR File
        4. Example: Running an Application from a JAR File
    16. 12. Exception Handling
      1. The Exception Class Hierarchy
      2. try Statements
        1. The try Statement
        2. The catch Clause
        3. The finally Clause
          1. Example: Using try statements
      3. The throw and throws Keywords
        1. Example: Passing Exceptions to Another Method
    17. 13. Arrays
      1. One-Dimensional Arrays
        1. Example: Creating a 1-D array
      2. Two-Dimensional Arrays
        1. Example: A 2-D Numerical Grid
      3. Arrays of More Than Two Dimensions
      4. Initializing Array Elements
        1. Example: Initializing Array Elements
      5. Accessing Array Elements
        1. Example: Accessing Array Elements
      6. Arrays as Method Arguments and Return Types
        1. Example: Passing an Array as a Method Argument
      7. Array Length
        1. Example: Using length
      8. Collection Classes in the Java API
    18. 14. The Java Class Libraries
      1. Package Naming Conventions
      2. The Core J2SE Libraries
        1. java.io
        2. java.lang
        3. java.math
        4. java.util
      3. The GUI Libraries
        1. java.awt
        2. java.awt.event
        3. javax.swing
        4. javax.swing.border
        5. javax.swing.event
        6. javax.swing.table
        7. javax.swing.text
        8. javax.swing.tree
    19. 15. Primitive Variable Wrapper and String Classes
      1. Primitive Variable Wrapper Classes
      2. Creating Primitive Variable Wrapper Class Objects
        1. Example: Using Primitive Variable Wrapper Classes
      3. Converting a Wrapper Class Object to a Primitive Value
        1. Example: Extracting Primitive Values from Wrapper Class Objects
      4. The parse() Methods
        1. Example: Using String Parsing Methods
      5. The String Class
      6. Obtaining String Objects
        1. Example: Creating Strings
      7. Concatenating Strings
        1. Example: Concatenating Strings
      8. Other Important String Class Methods
        1. Example: Using String Class Methods
      9. Converting Primitive and Reference Types to Strings
        1. Example: Converting Primitive and Reference Types to Strings
      10. Converting Strings to Primitive Values
        1. Example: Parsing an Input File
    20. 16. Built-in Math Functions
      1. Math and StrictMath Classes
      2. Mathematical Constants
      3. Absolute Value Methods
        1. Example: Using the abs() Method
      4. Power and Square Root Methods
        1. Example: Using the pow() and sqrt() Methods
      5. Transcendental Math Functions
        1. Example: Using log() and exp()
      6. Trigonometric Methods
        1. Example: Using the Trigonometric Methods
      7. Conversion Methods
        1. Example: Converting Angles
      8. Minimum and Maximum Methods
        1. Example: Finding the Maximum of a Collection of Data
      9. Rounding and Remainder Methods
        1. Example: Using Rounding and Remainder Methods
      10. Random Number Generator Methods
        1. Example: Using Random Number Generators
      11. The java.math Package
      12. Comparing the Built-in Math Capability of C, C++, Fortran, and Java
      13. References
        1. Bibliography
    21. 17. User-Defined Math Functions
      1. Basic Plan of Attack
      2. The Math2 Class
      3. Logarithm Methods
      4. Hyperbolic Trigonometric Methods
      5. The Gamma Function
      6. The Final Version of the Math2 Class
      7. Compiling the Math2 Class
      8. Using Math2 Class Methods
      9. Comparing Java, C, and Fortran Values
      10. References
        1. Bibliography
    22. 18. Building Class Hierarchies
      1. Defining the State and Behavior of a Gas Mixture
      2. The General Class Hierarchy Structure
      3. AbstractGas Class
      4. PerfectGas Class
      5. Air Class
      6. Realgas Class
      7. Species Class
      8. N2 Class
      9. N Class
      10. NitrogenGas Class
      11. Summary
      12. References
        1. Bibliography
    23. 19. Solving Systems of Equations
      1. General Considerations
      2. The EqnSolver Class
      3. Test Case
      4. Pivoting
      5. Gauss-Jordan Elimination
      6. Gaussian Elimination
      7. Lower-Upper Decomposition
      8. Matrix Inversion
      9. Testing the EqnSolver Class Methods
      10. Real Gas Viscosity Method
    24. 20. Solving Differential Equations
      1. Ordinary Differential Equations
      2. The ODE Class
      3. Initial Value Problems
      4. Runge-Kutta Schemes
      5. Example Problem: Damped Spring Motion
        1. SpringODE class
        2. Solving the Spring Motion ODE
      6. Embedded Runge-Kutta Solvers
      7. Other ODE Solution Techniques
      8. Two-Point Boundary Problems
      9. Shooting Methods
      10. Example Problem: Compressible Boundary Layer
        1. The CompressODE Class
        2. Solving the Compressible Boundary Layer Equations
      11. Other Two-Point Boundary Solution Techniques
      12. Partial Differential Equations
      13. References
        1. Bibliography
    25. 21. Integration of Functions
      1. General Comments
      2. Trapezoidal Algorithms
      3. Simpson's Rule
      4. Solving Improper Integrals
      5. Gaussian Quadrature Methods
      6. General Integral Types
      7. Example: Thin Airfoil Theory
      8. References
        1. Bibliography
    26. 22. Fourier Transforms
      1. The Fourier Transform
      2. Discrete Fourier Transform
      3. Analyzing Composite Signals
      4. Sampling Theory
      5. Spectral Leakage
      6. Fast Fourier Transform
    27. 23. Generic Class Libraries
      1. Analyzing the Problem
      2. Example: Least Squares Fit
      3. Implementing the Generic Part
      4. Implementing the Problem-Specific Part
      5. Testing the Generic Class Library
    28. 24. Data Modeling and Curve Fits
      1. Least Squares Fit to a Polynomial Equation
      2. The DataModeling Class
      3. The Polynomial Class
      4. Example Problem: Curve Fitting Specific Heat Data
      5. Fitting to Nonpolynomial Equations
      6. The Power Class
      7. Other Data Modeling Techniques
      8. References
        1. Bibliography
    29. 25. Java I/O
      1. General Concepts
      2. Byte Input Streams
        1. InputStream Class
        2. BufferedInputStream Class
        3. ByteArrayInputStream Class
        4. DataInputStream Class
        5. FileInputStream Class
        6. FilterInputStream Class
        7. ObjectInputStream Class
        8. Other InputStream Subclasses
      3. Byte Output Streams
        1. OutputStream Class
        2. BufferedOutputStream Class
        3. ByteArrayOutputStream Class
        4. DataOutputStream Class
        5. FileOutputStream Class
        6. FilterOutputStream Class
        7. ObjectOutputStream Class
        8. PrintStream Class
      4. Character Input Streams
        1. Reader Class
        2. BufferedReader Class
        3. FileReader Class
        4. InputStreamReader Class
        5. Other Reader Subclasses
      5. Character Output Streams
        1. Writer Class
        2. BufferedWriter Class
        3. FileWriter Class
        4. OutputStreamWriter Class
        5. PrintWriter Class
        6. Other Writer Subclasses
      6. Test Case: An Atmosphere Modeling Tool
      7. Getting Input from Command Line Arguments
      8. Using the Standard I/O Streams
      9. Reading and Writing to a File
      10. Saving and Restoring Objects
      11. The java.nio Packages
      12. References
        1. Bibliography
    30. 26. An Introduction to Java GUIs
      1. The Java GUI Libraries
      2. The AtmGUI Class
      3. Choosing a Container
      4. Selecting the GUI Components
      5. Adding the Components to the Container
      6. Event Handlers
      7. Other GUI elements
      8. The Final Form of the AtmGUI class
    31. 27. Creating Web-Based Applications Using Java Servlets
      1. Web-Based Application Basics
      2. Java Servlets
      3. Required Libraries and Tools
      4. Example: A Web-Based Atmosphere Modeling Tool
      5. HttpServlet Class
      6. General Form of an HttpServlet Subclass
      7. Extracting Input Parameters
      8. Running Server-Based Applications
      9. Sending Output Back to the Client Machine
      10. The AtmServlet Class
      11. Deploying the Web-Based Application
    32. Java Keywords