Friday, January 8, 2016

Bài 6: Từ Khóa Trong Java

1. Java Keywords: Từ khóa riêng trong Java, trong Java các từ khóa này không được sử dụng để đặt tên cho tên constant, tên variable hoặc cho các định danh khác.


abstractassertbooleanbreak
bytecasecatchchar
classconstcontinuedefault
dodoubleelseenum
extendsfinalfinallyfloat
forgotoifimplements
importinstanceofintinterface
longnativenewpackage
privateprotectedpublicreturn
shortstaticstrictfpsuper
switchsynchronizedthisthrow
throwstransienttryvoid
volatilewhile

Đối với các từ khóa này làm nhiều sẽ quen, trong eclipse hoặc netbean code đến từ khóa nó đổi màu => các bạn không phải lo lắng hay rối trí khi nhiều từ khóa như vậy

2. Comments trong Java
public class MyFirstJavaProgram{
//comment nhiều dòng
   /* This is my first java program.
    * This will print 'Hello World' as the output
    * This is an example of multi-line comments.
    */

    public static void main(String []args){
//comment một dòng
       // This is an example of single line comment
       /* This is also an example of single line comment. */
       System.out.println("Hello World"); 
    }
} 

3. Using Blank Lines: Dòng chỉ chứa  white space hoặc comment được hiểu như dòng trống

4. Java Modifiers:
Cũng như các ngôn ngữ khác, java cung cấp khả năng truy cập và modify classes, methods, etc., có hai dạng modifiers như sau:

  • Access Modifiers: default, public , protected, private
  • Non-access Modifiers: final, abstract, strictfp

No comments:

Post a Comment