Fundamental Programming Structures in Java
- A SIMPLE JAVA PROGRAM
- DATA TYPES
- ASSIGNMENTS AND INITIALIZATIONS
- CONTROL FLOW
- BIG NUMBERS
At this point, we are assuming that you successfully installed the Java SDK and were able to run the sample programs that we showed you in . It's time to start programming. This chapter shows you how the basic coding concepts such as data types, branches, and loops are implemented in Java. Unfortunately, in Java you can't easily write a program that uses a graphical user interface—you need to learn a fair amount of machinery to put up windows, add text boxes and buttons that respond to them, and so on. Since introducing the techniques needed to write GUI-based Java programs would take us too far away from our goal of introducing the basic coding concepts, the sample programs in this chapter will be "toy" programs, designed to illustrate a concept. All these examples will simply send output to a console window. When it comes to getting user input, we will stick to reading the information from a pop-up window. In particular, we will be writing apps rather than applets in this chapter. Finally, if you are an experienced C++ programmer, you can get away with just skimming this chapter: concentrate on the C/C++ notes that are interspersed throughout the text. Programmers coming from another background, such as Visual Basic, will find most of the concepts familiar and all of the syntax very different—you will want to read this chapter very carefully.