關鍵字(保留字)是編程語言中被賦予特殊意義的單詞,是整個語言範圍內預先保留的標識符,不能用來聲明對象、變量、函數、類名和參數等等標識符。
C++中的關鍵字
下面列出了C++(C++11)中的所有關鍵字(共73
個),與Java中不同的用紅色標出:
alignas |
const_cast |
extern |
noexcept |
static_assert |
union |
---|---|---|---|---|---|
alignof |
constexpr |
false |
nullptr |
static_cast |
unsigned |
asm |
continue | float | operator |
struct |
using |
auto |
decltype |
for | private | switch | virtual |
bool |
default | friend |
protected | template |
void |
break | delete |
goto | public | this | volatile |
case | do | if | register |
thread_local |
wchar_t |
catch | double | inline |
reinterpret_cast |
throw | while |
char | dynamic_cast |
int | return | true |
|
char16_t |
else | long | short | try | |
char32_t |
enum | mutable |
signed |
typedef |
|
class | explicit |
namespace |
sizeof |
typeid |
|
const | export |
new | static | typename |
Java中的關鍵字
下面列出了Java中的關鍵字(共50
個):
abstract |
continue | for | new | switch |
---|---|---|---|---|
assert |
default | goto | package |
synchronized |
boolean |
do | if | private | this |
break | double | implements |
protected | throw |
byte |
else | import |
public | throws |
case | enum | instanceof |
return | transient |
catch | extends |
int | strictfp |
try |
char | final |
interface |
short | void |
class | finally |
long | static | volatile |
const | float | native |
super |
while |