1. Trang chủ
  2. » Thể loại khác

Introduction to Java Giới thiệu về Java

28 3 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Session – Mục Introduction to Java Giới thiệu Java Trans & Edit:Hà Cường –T1204i Email: hacuong81@gmail.com Objectives – Các đối tượng  Describe real world entities as objects   Define a software object   Giải thích ý nghĩa ( tầm quan trọng ) Java Explain JDK and its tools   So sánh lớp đối tượng Define the significance of Java   Mơ tả giải thích cấu trúc lớp ( bao gồm đối tượng ) Compare classes and objects   Định nghĩa đối tượng phần mền Describe and explain the structure of a class   Mô tả thực thể giới thực đối tượng Giải thích JDK cơng cụ Describe a Java Virtual Machine (JVM)  Mô tả Máy Ảo Java (JVM) Learn Java by Example/ Session 1/2 of 29 Object – Đối tượng  An object is the software representation of a real world entity   Each object has some characteristics that describe entity   Một đối tượng hiển diện ( đại diện) phần mền cho một thực thể giới thực Mỗi đối tượng lại có số đặc tính riêng để mơ tả cho thực thể An object also executes actions that are activities or operations involving the object  Một đối tượng thực thi hành động hành động hay động thái có liên quan đến đối tượng Learn Java by Example/ Session 1/3 of 29 Software object – Đối tượng phần mềm  The concept of objects in the real-world can be defined as the software objects   Like its real-world counterpart, a software object has state and behavior   Khái niệm đối tượng giới thực định nghĩa đối tượng phần mềm Khi giới thực, đối tượng phần mềm có trạng thái trạng thái hành vi The software object stores its state in fields and exposes its behavior through methods  Đối tượng phần mềm lưu trạng thái trường biểu diễn hành vi thơng qua phương thức Learn Java by Example/ Session 1/4 of 29 Define a class – Định nghĩa Lớp A class is a template or blueprint which defines the state or behavior for all objects belong to that class  Một lớp mẫu hay thiết kế mà định nghĩa trạng thái hành vi cho tất đối tượng thuộc lớp Typically, in an object-oriented language, a class comprise fields and methods, collectively called as members, which depict the state and behavior respectively  Thông thường, ngôn ngữ hướng đối tượng, lớp bao gồm trường phương thức, gọi chung thành viên, mà miêu tả trạng thái hành vi tương ứng Learn Java by Example/ Session 1/5 of 29 Comparing Classes and Objects So sánh Lớp với Đối tượng  The table shows the difference between a class and an object:  Bảng bên cho thấy khác biệt lớp với đối tượng: Learn Java by Example/ Session 1/6 of 29 Evolution of Java- Sự phát triển Java  Java has, over the years, undergone a series of changes and evolved into the robust language that it is today Java , sau nhiều năm, qua loạt thay đổi trở thành ngôn ngữ mạnh mẽ ngày  Java Origins: Embedded Systems (1991-1994)  Java: A client-side Wonder (1995-1997)  Java: Moved into the Middle-tier (1997 to present)  Future Learn Java by Example/ Session 1/7 of 29 Platform – Nền    A platform is a hardware or software environment in which the program runs Nền môi trường phần cứng hay phần mềm để chương trình chạy The Java platform can be considered as an execution engine referred to as virtual engine and not a specific operating system or hardware Nền Java coi công cụ thực thi đề cập đến công cụ ảo phần cứng hay hệ điều hành cụ thể The Java platform comprises two essential components: Nền Java bao gồm phần  The Java Virtual Machine (JVM) Máy ảo Java  The Java Application Programming Interface (API) Giao diện lập trình ứng dụng Java Learn Java by Example/ Session 1/8 of 29 JVM – Máy ảo Java    The Java Virtual Machine (JVM) is the runtime environment and is available on different operating systems Máy ảo Java mơi trường thời gian chạy sử dụng hệ điều hành khác JVM executes complied Java programs (byte codes) JVM thực chương trình Java biên dịch ( mã byte ) It forms a layers of abstraction for: Một bao gồm :  Underlying hardware platform Nền tảng phần cứng sở  Operating system Hệ điều hành  Complied code Mã biên dịch Learn Java by Example/ Session 1/9 of 29 API – Giao diện lập trình ứng dụng  The Java Application Programming Interfaces (APIs) contains vast libraries of classes and other software components such as interfaces Giao diện lập trình ứng dụng Java (APIs) bao gồm nhiều thư viện lớp thành phần phần mềm khác giao diện  There are included as a part of the Java SDK chúng bao gồm phần Java SDK Learn Java by Example/ Session 1/10 of 29 Writing a Java Program –  Viết chương trình Java -1 Step 1: Declare a class: lớp: Bước 1: Khai báo class { class { } }  For instance: Ví dụ: class Helloworld { { } class Helloworld } Learn Java by Example/ Session 1/14 of 29 Writing a Java Program –  Step 2: Write the main method: main Viết chương trình Java -2 Bước 2: viết hàm public static void main (String[] args) { }  The main() method is the entry point for an application Hàm main() điểm bắt đầu cho ứng dụng  Step 3: Write desired functionality: Bước 3: viết hàm cần thiết System.out.println(“Welcome to the world of Java”); Learn Java by Example/ Session 1/15 of 29  Writing a Java Program – Viết chương trình Java -3 Step 4: Save the program: Bước 4: Lưu chương trình:  Save the file with a java extension Lưu tệp tin với đuôi mở rộng java  The class name and the file name would be the same most of Relationship the times Tên lớp tên tệp tin phải luôn giống trương trình tên tệp tin phải là: Helloworld.java Learn Java by Example/ Session 1/16 of 29 Executing a Java Program – Thực thi ứng dụng Java Learn Java by Example/ Session 1/17 of 29 Introduction to NetBeans IDE – Giới thiệu NetBeans IDE  NetBeans is an open-source integrated environment written purely in Java NetBeans mơi trường tích hợp mã nguồn mở viết hoàn toàn Java  Benefits of NetBeans IDE: Các lơi ích NetBeans IDE:  Builds IDE plug-in modules and supports rich client applications on the NetBeans platform Xây dựng khối mở rộng IDE hỗ trợ nhiều ( phong phú) ứng dụng client NetBeans  Provides graphics user interface for building, compiling, debugging and packaging of applications Cung cấp giao diện người dùng có đồ họa, biên dịch, gỡ lỗi đóng gói ứng dụng  Provides simple and user-friendly IDE configuring Cung cấp cấu hình IDE thân thiện đơn giản Learn Java by Example/ Session 1/18 of 29 Elements – Các thành phần  The NetBeans IDE has the following elements and views: NetBeans IDE có thành phần hiển thị bên dưới:  Menu Bar  Folders Views  Components Views  Coding and Design View  Output View Learn Java by Example/ Session 1/19 of 29 Menu Bar Learn Java by Example/ Session 1/20 of 29 Folder View - Xem thư mục    Projects Window  Source Packages  Test Packages  Libraries  Test Libraries Files Window Runtime Window Learn Java by Example/ Session 1/21 of 29 Components View  Inspector Window  Navigator Window Learn Java by Example/ Session 1/22 of 29 Coding and Design View  Source Editor  Design Form Learn Java by Example/ Session 1/23 of 29 Output View – Cửa sổ kết  The output view shows the status of complication and execution of the application Cửa sổ output cho thấy trạng thái việc thực thi ứng dụng Learn Java by Example/ Session 1/24 of 29 Programming in NetBeans IDE – Lập trình NetBeans IDE  Create a new project Tạo project  Specify Name and Location Chỉ tên project nơi lưu for the project  Select Set as Main Project and Chọn Set as Main Project and create Main Class Create Main Class  Write the code Viết code  Save the project Lưu project  Build Main Project Xây dựng Project  Run Main Project Thực thi Project Learn Java by Example/ Session 1/25 of 29 Single-line Comments – Chú thích dịng  Two ways:    Beginning-of-line comment End-of-line comment Conventions:   Provide a space after the forward slashes Capitalize the first letter of the first word Learn Java by Example/ Session 1/26 of 29 Multi-line Comments  Starts with /*  Ends with */ Learn Java by Example/ Session 1/27 of 29 Java-doc Comments    A Javadoc comment is used to document It starts with /** and ends with */ The javadoc command can be used for generating Javadoc comments Learn Java by Example/ Session 1/28 of 29 ... tin phải là: Helloworld.java Learn Java by Example/ Session 1/16 of 29 Executing a Java Program – Thực thi ứng dụng Java Learn Java by Example/ Session 1/17 of 29 Introduction to NetBeans IDE –... Components Views  Coding and Design View  Output View Learn Java by Example/ Session 1/19 of 29 Menu Bar Learn Java by Example/ Session 1/20 of 29 Folder View - Xem thư mục    Projects Window  Source... Files Window Runtime Window Learn Java by Example/ Session 1/21 of 29 Components View  Inspector Window  Navigator Window Learn Java by Example/ Session 1/22 of 29 Coding and Design View  Source

Ngày đăng: 10/10/2022, 23:45

Xem thêm:

HÌNH ẢNH LIÊN QUAN

 Bảng bên dưới cho thấy sự khác biệt giữa một lớp với một đối tượng: - Introduction to Java Giới thiệu về Java
Bảng b ên dưới cho thấy sự khác biệt giữa một lớp với một đối tượng: (Trang 6)
w