Chapter 2. Moving from Fortran to JavaIf you are moving from Fortran to Java, there will be a learning curve. Java is a C and C++ based language, and the basic syntax used by Java is different than Fortran. What's more, Java is an object-oriented language. You will have to learn to think and program in an object-oriented manner. The good news is that simplicity was one of the design goals of the developers who created Java. It's much easier moving from Fortran to Java than it is to move from Fortran to a language like C++.
You will quickly realize that Java is more powerful and versatile than Fortran. There are more programming constructs and more ways of customizing programming elements. Java is a more comprehensive language as well. It offers a lot more features and can be used for a wider range of programming disciplines. The Fortran libraries are limited in scope, consisting
This chapter will shed some light on the things you will have to learn and consider when moving to the Java world. It will focus not only on the basic syntactical differences but also touch
The specific topics we will discuss in this chapter are ”
|
Program Structure
Java is an object-oriented, C-based language. Fortran is
One of the big differences between Fortran and Java is the basic program structure of the two languages. A Fortran program consists of a main program section and zero or more subroutines or functions. Program execution starts at the top of the main program section. The main program section is
Java is an object-oriented programming language. The fundamental building block of a Java program is a named block of code called a
class.
Classes are usually designed to be self-contained. They declare fields (i.e.,
Classes define the structure of the objects that make Java object oriented. An object is an instance of a class. Java arrays are also objects although no explicit class defines them. An object will have its own copy of the nonstatic data
|