Cú pháp Java

Một đoạn mã Java ngắn với từ khóa được làm nổi bằng phông chữ màu xanh đậm

Cú pháp của ngôn ngữ lập trình Java là tập các quy tắc để xác định các viết và diễn giải một chương trình Java.

Cú pháp của nó hầu hết có nguồn gốc từ CC++. Không như trong C++, trong Java không có các hàm hoặc biến toàn cục, nhưng có các thành viên dữ liệu cũng được xem là biến toàn cục (global variable). Tất cả mã thuộc về lớp và tất cả giá trị là đối tượng. Ngoại lệ duy nhất là các kiểu nguyên thủy (primitive type), vốn không được thể hiện bởi một thực thể của lớp vì lí do hiệu suất (mặc dù nó có thể được chuyển đổi tự động thành đối tượng và ngược lại thông qua autoboxing). Một số tính năng như nạp chồng toán tử (operator overloading) hay kiểu số nguyên không dấu (unsigned integer)được bỏ qua để đơn giản hóa ngôn ngữ và để tránh các lỗi lập trình có thể xảy ra.

Cú pháp Java dần được mở rộng trong 11 bản phát hành JDK, hỗ trợ khả năng như lập trình tổng quáthàm số hằng (function literal - còn gọi là biểu thức lambda trong Java).

Xem thêm

Tham khảo

  • Patrick Naughton, Herbert Schildt. Java 2: The Complete Reference, third edition. The McGraw-Hill Companies, 1999. ISBN 0-07-211976-4
  • Vermeulen; Ambler; Bumgardner; Metz; Misfeldt; Shur; Thompson (2000). The Elements of Java Style. Cambridge University Press. ISBN 0-521-77768-2.
  • Gosling, James; Joy, Bill; Steele, Guy; Bracha, Gillad (2005). Java Language Specification (ấn bản thứ 3). Addison-Wesley Professional. Truy cập ngày 3 tháng 12 năm 2008.

Liên kết ngoài

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.