Murach's Beginning Java 2, SDK 1.4

This chapter shows how to write a complete Java application that uses comments, primitive data types, variables, strings, dialog boxes, if statements, and a while loop. To see how well this chapter works, you can download this chapter for free.

Chapter 2 Java language essentials (part 1)
Basic coding skills 36
How to code comments 36
How to code statements 36
How to create identifiers 38
How to declare a class 40
How to declare a main method 42
How to work with the primitive data types 44
The eight primitive data types 44
How to initialize variables 46
How to initialize constants 46
How to code assignment statements 48
How to code arithmetic expressions 50
Four classes for working with data 52
How to use the String class to create a String object 52
How to use two methods of the String class 54
How to join two or more strings 54
How to use the Integer and Double classes 56
How to use two methods of the System.out object to print data to the console 58
How to use the JOptionPane class for input and output 62
How to import classes 62
How to use the JOptionPane class to get input 64
How to use the System.exit method to end a JOptionPane thread 64
How to use two more methods of the JOptionPane class 66
How to code control statements 68
How to code conditional expressions 68
How to code if/else statements 70
How to code while statements 72
The Invoice application 74
The dialog boxes for the application 74
The code for the application 74
Perspective 76
t




Murach's Beginning Java 2

Learn more about this book

Add this book to your cart

Download this chapter

See the Java 1.5 edition