Home > Store

Technical Java: Applications for Science and Engineering

Register your product to gain access to bonus material or receive a coupon.

Technical Java: Applications for Science and Engineering

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2003
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-101815-9
  • ISBN-13: 978-0-13-101815-0

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

Downloads

Downloads

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).

Sample Content

Downloadable Sample Chapter

Download the Sample Chapter related to this title.

Table of Contents



Preface.


Acknowledgments.


1. Introduction to Java.

A Brief History of Java. What Java Is. Installing Java on Your Machine. Compiling and Running Java Programs.



2. Moving from Fortran to Java.

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.



3. Moving from C to Java.

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.



4. Moving from C++ to Java.

Basic Syntax. Preprocessor Directives. Data Types. Pointers. Structures, Unions, Enumerations. Inheritance and Interfaces. Built-In Math Functions. Standard I/O. Strings. Memory Management.



5. An Overview of Object-Oriented Programming Concepts.

Objects. Classes. Encapsulation. Inheritance. Polymorphism.



6. Basic Syntax.

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.



7. Classes.

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.



8. Variables.

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.



9. Methods.

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.



10. Interfaces.

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.



11. Packages and JAR Files.

Defining a Package. import Declarations. CLASSPATH Environment Variable. Packages and Access Control. JAR Files.



12. Exception Handling.

The Exception Class Hierarchy. try Statements. The try Statement. The catch Clause. The finally Clause. The throw and throws Keywords.



13. Arrays.

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.



14. The Java Class Libraries.

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.



15. Primitive Variable Wrapper and String Classes.

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.



16. Built-in Math Functions.

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.



17. User-Defined Math Functions.

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.



18. Building Class Hierarchies.

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.



19. Solving Systems of Equations.

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.



20. Solving Differential Equations.

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.



21. Integration of Functions.

General Comments. Trapezoidal Algorithms. Simpson's Rule. Solving Improper Integrals. Gaussian Quadrature Methods. General Integral Types. Example: Thin Airfoil Theory. References.



22. Fourier Transforms.

The Fourier Transform. Discrete Fourier Transform. Analyzing Composite Signals. Sampling Theory. Spectral Leakage. Fast Fourier Transform.



23. Generic Class Libraries.

Analyzing the Problem. Example: Least Squares Fit. Implementing the Generic Part. Implementing the Problem-Specific Part. Testing the Generic Class Library.



24. Data Modeling and Curve Fits.

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.



25. Java I/O.

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.



26. An Introduction to Java GUIs.

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.



27. Creating Web-Based Applications Using Java Servlets.

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.



Appendix: Java Keywords.


Index.

Preface

Preface

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.

Why Is Java a Good Technical Programming Language?

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.

The Structure of This Book

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.

What This Book Is Not

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.

Index

Download the Index file related to this title.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020