The difficulty

primary

Learning time

30 minutes

Suits the crowd

Zero basis

Development of language

Java

The development environment

  • JDK v11
  • IntelliJ IDEA v2018.3

1. What are the keywords?

Let’s take a look at baidu Baike’s description of Java keywords:

Java keywords are predefined identifiers in the computer language that have special meaning, sometimes called reserved words, and special meaning variables. Java keywords have special meaning for the Java compiler. They are used to represent a data type, or the structure of a program, etc. Keywords cannot be used as variable names, method names, class names, package names, and parameters.

To list a few important points:

  • A computer language identifier that has special meaning
  • Also called reserved word
  • Has special meaning for the Java compiler
  • Used to represent data types or program structures
  • Keywords cannot be used as variable names, method names, class names, package names, or parameters

Each sentence is a bit long, so let’s simplify it:

  • identifier
  • Reserved words
  • The Java compiler
  • The data type
  • The variable name
  • The method name
  • The name of the class
  • The package name
  • parameter

Next, let’s explain them briefly in turn.

2. The identifier

Identifiers will be covered in the next chapter, but here’s a quick overview.

An identifier is a name. What does the name mean? For example, the following Java program:

You’re all familiar with it, as explained in the previous chapter.

So public, for example, if you put a public word in there, the computer knows that you’re going to make the Main class public, and if you haven’t learned the class, people will take it as a secret, and the computer knows that you’re going to make the Main class public.

In other words, you want to tell the computer I’m going to disclose the secret of Main, the computer doesn’t know human language, so you have to tell the computer that it understands computer language, and Java is a computer language, and in Java for disclosing something, you say public, and the computer knows that you’re going to disclose the secret of Main.

A Java keyword is a special identifier defined in the computer language. A Java keyword is a special identifier defined in the computer language.

3. The reserved words

Reserved word is another name for a keyword.

4. The Java compiler

Let’s start with a file:

As we all know, TXT is a text format, you can write in it. Now I’ll write the following inside:

TXT can only do two things, you open or look inside the content, or write some content. How do I get the computer to say “Hello Java!” on the screen for me? ?

First, you should write something that Java understands, such as the one above. The next step is to make the file look like a Java file type. TXT we all know is text file type, how to express Java file type?

This section describes a new file type. Java. Java is the Java file type.

For example:

This is a Java file, Main is the file name, and the icon in front of Main is the icon of the program that opens the file by default.

We see that the category here says “Java source” :

Everything written in a Java file is called Java source code.

5. Data types

TXT. TXT indicates that the file is a text file. Java indicates that the file is a Java file type. Similarly, a data type is a type that represents data. So what is data?

Like 123, 3.14, “Do you play games?” Wait, this is all data. What are their data types?

123 is an integer, as everyone learned in elementary school, 3.14 is a decimal. “Do you play games?” Is a sentence. So their data types are as follows:

123 is an integer, 3.14 is a decimal. “Do you play games?” It’s a string. Maybe strings are hard to understand.

A character is a word or a symbol, “you”, “play”, “play”, “do”, “?” It’s all characters. Among them:

Words: “you”, “play”, “you”, “play”, “do”

Symbol: “?”

A string is a concatenation of characters. So, “Do you play games?” .

So how do you represent data types in Java? There are several data types mentioned here in advance, which will be explained in later chapters.

123 is an integer denoted by int.

3.14 is a decimal and is represented by float.

“Do you play games?” Is a String and is represented by String.

Simple demo:

The three new lines will be explained below.

6. The variable name

Variable names, literally, we know that a variable name is the name of a variable.

Let’s take a look at the program:

Each of these three lines defines a variable:

The type of the variable, the data type, is written first:

The type immediately following the variable is the variable name:

The “=” immediately following the variable name is the assignment symbol:

The “=” assignment symbol is followed by the specific value:

Values are followed by “;” A semicolon to indicate the end of a statement:

All right, so these three lines of code have a general idea, but in general, they represent defining a variable.

7. The method name

Let’s look at this program again:

As mentioned earlier, the second line defines a method:

Which method name is it?

Main is the name of the method, so stay tuned for more information about the method in the following sections.

8. The name of the class

Again, this program:

Where, the class name is:

Main is the name of the class. Stay tuned for more on the class in the following sections.

9. The package name

Let’s take a look at an application that looks like this with the package added:

Where, package name:

Main is the name of the package. Stay tuned for more details about the package in the following sections.

Parameters of 10.

Again, to demonstrate the program:

Only methods have parameters, so let’s look at methods:

Arguments are written in parentheses, so:

Where the argument type is an array of strings:

The parameter name is args:

At this point, the content analysis describing Java keywords is complete. Let’s look at all the keywords in Java.

11. All the keywords in Java

Show all keywords in Java:

The text version:

abstractassertbooleanbreakbyte

casecatchcharclassconst

continuedefaultdodoubleelse

enumextendsfinalfinallyfloat

forgotoifimplementsimport

instanceofintinterfacelongnative

newpackageprivateprotectedpublic

returnstrictfpshortstaticsuper

switchsynchronizedthisthrowthrows

transienttryvoidvolatilewhile

12. General meaning of all keywords

Thanks to Baidu Encyclopedia:

The text version:

abstract

Key words: abstract

Meaning: Indicates that a class or member method has abstract properties

assert

Keyword: Assert

Meaning: Assertion, used for program debugging

boolean

Keyword: Boolean

One of the basic data types, a Boolean type

break

Key word: break

Meaning: Jump a block ahead of time

byte

Keyword: byte

One of the basic data types, the byte type

case

Key words: case

Meaning: Used in a switch statement to indicate a branch

catch

Keyword: catch

Meaning: Used in exception handling to catch exceptions

char

Key word: char

One of the basic data types, the character type

class

Key word: class

Declare a class

const

Keyword: const

Meaning: Reserved keywords without specific meanings

continue

Keywords: continue

Return to the beginning of a block

default

Keyword: default

Meaning: Default, for example, in switch statements, to indicate a default branch

do

Keyword: do

Meaning: used in a do-while loop

double

Key word: double

One of the basic data types, the double – precision floating – point type

else

Keyword: else

Meaning: Used in conditional statements to indicate a branch when a condition is not established

enum

Keyword: enum

Meaning: enumeration

extends

Keyword: extends

Meaning: Indicates that a type is a subtype of another type. Common types here are classes and interfaces

final

Key word: final

Meaning: Used to describe final properties, indicating that a class cannot subclass, or that member methods cannot be overridden, or that the value of a member field cannot be changed, to define constants

finally

Keyword: finally

Meaning: Used to handle exceptions and declare a block of statements that are almost certain to be executed

float

Keyword: float

One of the basic data types, the single-precision floating-point type

for

Key word: for

Meaning: a leading word in a circular structure

goto

Key word: goto

Meaning: Reserved keywords without specific meanings

if

Key word: if

Meaning: The lead word of a conditional statement

implements

Keyword: implements

Meaning: Indicates that a class implements a given interface

import

Keyword: import

Meaning: Indicates that you want to access the specified class or package

instanceof

Key word: instanceof

Meaning: Used to test whether an object is an instance object of the specified type

int

Key word: int

One of the basic data types, the integer type

interface

Key word: interface

Meaning: Interface

long

Key word: long

One of the basic data types, long integer type

native

Keywords: native

Meaning: Used to declare that a method is implemented in a computer-related language such as C/C++/FORTRAN

new

Key word: new

Meaning: Used to create a new instance object

package

Keyword: package

Meaning: package

private

Key word: private

Meaning: an access control mode: private mode

protected

Keyword: protected

Description: An access control mode: protected mode

public

Key word: public

Description: An access control mode: shared mode

return

Keyword: return

Returns data from a member method

short

Key word: short

One of the basic data types, the short integer type

static

Keyword: static

Meaning: Indicates a static attribute

strictfp

Key words: STRICtFP

Meaning: used to declare that FP_strict (single-precision or double-precision floating point number) expressions comply with IEEE 754 arithmetic specification [1]

super

Key word: super

Meaning: a reference to or constructor for the parent type of the current object

switch

Key word: switch

Meaning: a guide word for the structure of a branch statement

synchronized

Key word: synchronized

Meaning: Indicates that a piece of code needs to be executed synchronously

this

Key word: this

Meaning: a reference to the current instance object

throw

Key word: throw

Meaning: Throws an exception

throws

Keyword: throws

Definition: Declares all exceptions that need to be thrown in the currently defined member method

transient

Keywords: TRANSIENT

Definition: Declare a member domain that is not serialized

try

Keyword: try

Meaning: Try a block that might throw an exception

void

Keyword: void

Description: Declares that the current member method has no return value

volatile

Key word: volatile

Meaning: Indicates that two or more variables must change synchronously

while

Key words: while

Meaning: Used in loop construction

13. Just remember the common Java keywords

There are many Java keywords, but you just need to remember the most common ones and look up the rest.

At this point, the Java keyword related content to explain the end, please continue to pay attention to more content.

Answering questions

If you have questions or want to learn more about cutting-edge technology, please leave them in the comments below, and I’ll answer them for you.

The previous chapter

“Full Stack 2019” Java Chapter 9: Explains the first program

The next chapter

Full Stack 2019 Java Chapter 11: Identifiers

A study group

Join a synchronous learning group for mutual communication and progress.

  • Method 1: Follow the headline number gorhaf, private message “Java study Group”.
  • Method 2: follow the public account gorhaf, reply “Java learning group”.

Full stack engineer learning program

Follow us and join the “Full stack Engineer Learning Program”.

Copyright statement

Original is not easy, shall not be reproduced without permission!