Java 关键字是编程语言中的保留字,不用作标识符。 Java 关键字称为保留字,因为它们是您所使用的语言“保留”的。它们具有在语言库中定义的特殊含义。
开始您的免费软件开发课程
网络开发、编程语言、软件测试及其他
Java 编程语言中的概念
与任何其他编程语言一样,Java 编程语言中的关键字是具有特殊含义的保留字。关键字是为内部流程保留的,并且具有一些预定义的操作。在 Java 中,如果以其他方式使用关键字,程序或代码将遇到“编译时错误”。为了便于程序员使用和识别关键字,通常在 Java 中将它们稍微“突出显示”。
Java 中的关键字列表
我们尝试按字母顺序列出下面 Java 中当前使用的重要关键字。您还可以按照给定的示例来观察每个关键字的工作原理。让我们一一看看这些关键词。
1. Abstract: Abstract The keyword is used to declare a class to be used later in the abstract program. Abstract used with a class declaration makes that class an abstract and specifies that the class will be implemented in a subclass at a later stage. Below is an example of the usage of the ‘Abstract’ keyword.2. Assert: The ‘assert’ keyword was added to Java 1.4. This keyword allows a programmer to test his assumptions in the program.
3. Boolean: Boolean is a data type that can hold only two values; it’s either a ‘True’ or a ‘False’.
4. Break: This keyword helps the programmer want his code to jump out of a loop, for example, a For loop. It’s a control statement that breaks the current flow of the execution on a specific condition provided by the programmer.
5. Byte: Byte keyword is one of the data types that are able to store whole numbers. The numbers range from -128 to 127
6. Case: Case keyword is used in a switch statement. The ‘case’ keyword creates a block of code and marks it.
7. Catch: The ‘catch’ keyword catches the exceptions that were created by the ‘try’ statements. The catch block is used after Try block.
8. Char: The ‘char’ is one of the data types that is used to hold one character at a time.
9. Class: The class keyword is used to create a class in java. Everything that runs in Java programming resides inside a class.
10. Continue: The ‘continue’ keyword is used to skip the current execution and continues to the next step in a loop like a For loop or a While loop.
11. Default: The ‘Default’ keyword is used to create a default block of code containing a set of statements executed by default if the required case is not present.
12. Do: The ‘do’ keyword is used when creating a ‘do-while’ loop. The ‘do’ block is executed at least once before checking the condition in a while block.
13. Double: The ‘double’ keyword is one of the data types used for holding fractional numbers. The fractional numbers range from 1.7e – 308 to 1.7e + 308. While declaring a fraction, the value is ended with a ‘d’.
14. Else: The ‘Else’ keyword is used to create a block of code that will be executed if the condition is not ‘True’ in an ‘If’ statement.
15. Enum: The ‘enum’ keyword is used to create enumerations, unchangeable data types. The enum keyword defines a fixed set of constants.
16. Extends: Extends keyword is used to inherit properties of a superclass’s attributes and methods by a subclass.
17. Final: The ‘Final’ keyword is used to set a final value to a variable, making it impossible to overwrite or change altogether. If the value of a final variable is tried to change, it throws an error.
When hovered over, it shows the following error.
18. Finally: Finally keyword is used along try and catch statements, which has a block that is executed even if the exception is not handled.
19. Float:float 关键字是一种数据类型,保存范围从 3.4e−038 到 3.4e+038 的小数。声明小数时,该值应以“f”结尾。
20。 For:‘For’关键字用于创建一个循环,一个for一个循环。 for 循环多次执行所包含的代码集,这些代码在 for 循环条件语句中定义。
21. If:“If”关键字用于创建在条件为“True”时执行的一组或代码块或语句。
22。 Implements:Implement 是另一个为声明接口而保留的关键字。它在类声明期间使用,并指定一个或多个接口。
23. Import:import 关键字用于导入包或一个或多个类,或者也可能是一个接口。
24。 Instanceof:‘instanceof’关键字用于检查相关对象是否是类或接口的实例。
25。 Int:‘int’关键字是声明整数类型的数据类型之一。
26。 Interface:interface关键字用于声明仅包含抽象方法的特殊类型的类。为了访问接口方法,接口必须被“实现”,就像我们通过使用“implements”关键字由另一个类使用继承概念一样。
27。 Long:“long”关键字又是保存整数的数据类型之一。它们的范围从 -9223372036854775808 到 9223372036854775808。整个数值应以“L”结尾。
28。 New:‘new’关键字用于创建对象。
29。 Package:‘package’关键字用于创建包。30。 Private:‘private’关键字用于为私有模式类创建属性或方法。 “Private”是一个访问修饰符,仅允许声明的类使用私有属性或属性或方法。
31。 Protected:“Protected”是一个访问修饰符,允许属性或方法只能由相同的包或子类使用。
32。 Public:“public”关键字是另一个访问修饰符,它允许一个类在其自身内使用公共定义的类的属性或方法等。
下面是一个公共定义的类“test.java”和另一个类“Test2.java”,访问它。类 – Test2.java
33。 Return:return关键字可以作为方法的执行结束,也可以用来从方法返回一个值。
34. Short:‘short’关键字是一种数据类型,用于保存从 -32768 到 32767 范围内的整数。
35。 Static:‘static’关键字用于创建静态方法,这意味着可以在不创建其对象的情况下调用该方法。
36. Super:‘super’关键字用于调用父类或父类或对象。
37. Switch:‘switch’关键字用于在不同的情况下创建不同的场景,并用于从中选择一个。 switch 语句包含一个值或表达式,然后将其与所有存在的情况进行比较,并选择匹配的一个。
38. this:‘this’关键字用于引用方法或构造函数的当前对象。
39. Throw:“throw”关键字用于向用户在屏幕上抛出异常消息。
40。 Throws:当程序员想要决定并抛出异常类型时,可以使用“throws”关键字。41 特别是。 Try:“try”关键字启动“try-catch”块。 “try”块是测试异常的地方。
42。 Void:“void”关键字与方法一起使用时,指定该方法没有返回值。
43。 While:“while”关键字创建一个循环,其语句中带有条件。循环执行直到语句为真。
关键字是Java编程语言中保留的、具有特殊含义的标记。它们在语言中具有保留的用途和预定义的操作。
以上是Java关键字的详细内容。更多信息请关注PHP中文网其他相关文章!

本文讨论了使用Maven和Gradle进行Java项目管理,构建自动化和依赖性解决方案,以比较其方法和优化策略。

本文使用Maven和Gradle之类的工具讨论了具有适当的版本控制和依赖关系管理的自定义Java库(JAR文件)的创建和使用。

本文讨论了使用咖啡因和Guava缓存在Java中实施多层缓存以提高应用程序性能。它涵盖设置,集成和绩效优势,以及配置和驱逐政策管理最佳PRA

本文讨论了使用JPA进行对象相关映射,并具有高级功能,例如缓存和懒惰加载。它涵盖了设置,实体映射和优化性能的最佳实践,同时突出潜在的陷阱。[159个字符]

Java的类上载涉及使用带有引导,扩展程序和应用程序类负载器的分层系统加载,链接和初始化类。父代授权模型确保首先加载核心类别,从而影响自定义类LOA

本文解释了用于构建分布式应用程序的Java的远程方法调用(RMI)。 它详细介绍了接口定义,实现,注册表设置和客户端调用,以解决网络问题和安全性等挑战。

本文详细介绍了用于网络通信的Java的套接字API,涵盖了客户服务器设置,数据处理和关键考虑因素,例如资源管理,错误处理和安全性。 它还探索了性能优化技术,我

本文详细介绍了创建自定义Java网络协议。 它涵盖协议定义(数据结构,框架,错误处理,版本控制),实现(使用插座),数据序列化和最佳实践(效率,安全性,维护


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

SublimeText3 Linux新版
SublimeText3 Linux最新版

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3汉化版
中文版,非常好用

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。