Lecture Introduction to programming with Java - Chapter 3: Java basics

The main contents of this chapter include all of the following: First java program, comments, class name/source code filename, main method heading, braces, , compilation and execution, program template, identifiers, variables, assignment statements, initialization statements. | Chapter 3 - Java Basics First Java Program Comments Class Name / Source Code Filename main Method Heading Braces Compilation and Execution Program Template Identifiers Variables Assignment Statements Initialization Statements 1 Chapter 3 - Java Basics Numeric Data Types – int, long Numeric Data Types – float, double Constants Arithmetic Operators Expression Evaluation Increment and Decrement Operators Compound Assignment Operators Type Casting Character Type - char Escape Sequences Primitive Variables vs. Reference Variables String Basics String Methods: equals, equalsIgnoreCase, length, charAt Input - the Scanner Class 2 First Java Program /*************************************** * * John Dean * * This program prints a hello message. ***************************************/ public class Hello { public static void main(String[] args) { ("Hello, world!"); } } // end class Hello 3 Comments Include comments in your programs in order to make them more readable/understandable. Block comment syntax: /* . */ (Note: The /* and */ can optionally span multiple lines) One line comment syntax: // Commented text is ignored by the compiler. Style requirement: Include a prologue section at the top of every program. The prologue section consists of: line of *'s filename programmer's name blank line program description line of *'s blank line 4 Class Name / Source Code Filename All Java programs must be enclosed in a class. Think of a class as the name of the program. The name of the Java program's file must match the name of the Java program's class (except that the filename has a .java extension added to it). Proper style dictates that class names start with an uppercase first letter. Since Java is case-sensitive, that means the filename should also start with an uppercase first letter. Case-sensitive means that the Java compiler does distinguish between lowercase and uppercase letters. 5 main Method Heading . | Chapter 3 - Java Basics First Java Program Comments Class Name / Source Code Filename main Method Heading Braces Compilation and Execution Program Template Identifiers Variables Assignment Statements Initialization Statements 1 Chapter 3 - Java Basics Numeric Data Types – int, long Numeric Data Types – float, double Constants Arithmetic Operators Expression Evaluation Increment and Decrement Operators Compound Assignment Operators Type Casting Character Type - char Escape Sequences Primitive Variables vs. Reference Variables String Basics String Methods: equals, equalsIgnoreCase, length, charAt Input - the Scanner Class 2 First Java Program /*************************************** * * John Dean * * This program prints a hello message. ***************************************/ public class Hello { public static void main(String[] args) { ("Hello, world!"); } } // end class Hello 3 Comments Include comments in your programs in .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.