tailieunhanh - Bài giảng Cấu trúc dữ liệu: Chương 1 - Nguyễn Xuân Vinh
Bài giảng Cấu trúc dữ liệu - Chương 1: Java basic trình bày về basic language elements, data types, literal, variables, constant, JVM memory, why string is immutable. Đây là tài liệu tham khảo dùng cho sinh viên chuyên ngành Công nghệ thông tin. | JAVA BASIC Nguyễn Xuân Vinh nguyenxuanvinh@ CẤU TRÚC DỮ LIỆU DATA STRUCTURES [214441] 1. Basic Language Elements Identifiers A name in a program is called an identifier An identifier in java is composed of a sequence of characters (include: letter, digits or connecting symbols ($, _). The first character in an identifier can’t be a digit. Identifiers in java are case sensitive. Keywords Key words are reserved identifiers. In java, all keywords are in lower case. Literals A literal denotes a constant value of a particular data type The value a literal represents remains unchanged in the program. 2. Data Types Primitive Data Types Types Length Values Default value byte 8-bit -28 28 – 1 0 short 16-bit -216 216 – 1 0 int 32-bit -231 231 – 1 0 long 64-bit -263 263 – 1 0 float 32-bit IEEE 754 floating point +/ +/- double 64-bit IEEE 754 floating point +/ +/ boolean 1-bit true, . | JAVA BASIC Nguyễn Xuân Vinh nguyenxuanvinh@ CẤU TRÚC DỮ LIỆU DATA STRUCTURES [214441] 1. Basic Language Elements Identifiers A name in a program is called an identifier An identifier in java is composed of a sequence of characters (include: letter, digits or connecting symbols ($, _). The first character in an identifier can’t be a digit. Identifiers in java are case sensitive. Keywords Key words are reserved identifiers. In java, all keywords are in lower case. Literals A literal denotes a constant value of a particular data type The value a literal represents remains unchanged in the program. 2. Data Types Primitive Data Types Types Length Values Default value byte 8-bit -28 28 – 1 0 short 16-bit -216 216 – 1 0 int 32-bit -231 231 – 1 0 long 64-bit -263 263 – 1 0 float 32-bit IEEE 754 floating point +/ +/- double 64-bit IEEE 754 floating point +/ +/ boolean 1-bit true, false false char 16-bit Unicode \u0000 (0) \uffff () Primitive Data Types Reference Data Types Reference to Tham chiếu tới một giá trị hay là tập hợp các giá trị mà biến khai báo. Các kiểu dữ liệu dẫn xuất: 3. Literal The new keyword isnt used when initializing a variable of a primitive type. A literal is the source code representation of a fixed value. Literals are represented directly in your code without requiring computation boolean result = true; char capitalC = C; byte b = 100; short s = 10000; int i = 100000; 4. Variables Parameters The variables that are listed as part of a method declaration. Each parameter must have a unique name and a defined data type. public void method(int a, double b, boolean c) { . } Instance variables Every object of the class will have its own copies of these variables, which are local to object The values of these variables at any given time constitute the state of the object Instance variables exist as long as object they belong
đang nạp các trang xem trước