Chapter 2 introduction to Java applications. In this chapter you will learn: To write simple Java applications, to use input and output statements, Java’s primitive types, basic memory concepts, to use arithmetic operators, the precedence of arithmetic operators, to write decision-making statements, to use relational and equality operators. | 2 Introduction to Java Applications What’s in a name? that which we call a rose By any other name would smell as sweet. William Shakespeare When faced with a decision, I always ask, “What would be the most fun?” Peggy Walker “Take some more tea,” the March Hare said to Alice, very earnestly. “I’ve had nothing yet,” Alice replied in an offended tone: “so I can’t take more.” “You mean you can’t take less,” said the Hatter: “it’s very easy to take more than nothing.” Lewis Carroll OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java’s primitive types. Basic memory concepts. To use arithmetic operators. The precedence of arithmetic operators. To write decision-making statements. To use relational and equality operators. Introduction First Program in Java: Printing a Line of Text Modifying Our First Java Program Displaying Text with printf Another Java Application: Adding Integers Memory . | 2 Introduction to Java Applications What’s in a name? that which we call a rose By any other name would smell as sweet. William Shakespeare When faced with a decision, I always ask, “What would be the most fun?” Peggy Walker “Take some more tea,” the March Hare said to Alice, very earnestly. “I’ve had nothing yet,” Alice replied in an offended tone: “so I can’t take more.” “You mean you can’t take less,” said the Hatter: “it’s very easy to take more than nothing.” Lewis Carroll OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java’s primitive types. Basic memory concepts. To use arithmetic operators. The precedence of arithmetic operators. To write decision-making statements. To use relational and equality operators. Introduction First Program in Java: Printing a Line of Text Modifying Our First Java Program Displaying Text with printf Another Java Application: Adding Integers Memory Concepts Arithmetic Decision Making: Equality and Relational Operators (Optional) Software Engineering Case Study: Examining the Requirements Document Wrap-Up Introduction Java application programming Display messages Obtain information from the user Arithmetic calculations Decision-making fundamentals First Program in Java: Printing a Line of Text Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays a line of text Illustrates several important Java language features Outline First Program in Java: Printing a Line of Text (Cont.) Comments start with: // Comments ignored during program execution Document and describe code Provides code readability Traditional comments: /* . */ /* This is a traditional comment. It can be split over many lines */ Another line of comments Note: line numbers not part of program, added for reference 1 // Fig. : 2 // .