java反射用法示例_Java包| 类型,用法,示例

java反射用法示例

配套 (Packages)

Packages in Java is simply a mechanism to encapsulate (i.e. to put in a short and concise form) a group of classes,interfaces,enumerations, sub packages, etc. In real world, application is developed in such a manner so that we can easily maintain each module. To create package is simply use package keyword with name of the package at first statement in the program.

Java包只是一种封装(即,以简明扼要的形式)一组类,接口,枚举,子包等的机制。在现实世界中,应用程序的开发方式使我们可以轻松地维护每个模块。 要创建包,只需在程序的第一条语句中使用带有包名称的package关键字。

There are two type of Packages that are found in java,

java中有两种类型的Packages,

  1. User defined packages

    用户定义包

  2. In Built packages

    内置包装

1)用户定义的套餐 (1) USER DEFINED PACKAGES)

The Packages that are created by the user to differentiate between the classes and the interfaces that are made in their projects are user defined packages.

用户创建的用于区分类和在其项目中创建的接口的包是用户定义的包。

2)内置包装 (2) IN-BUILT PACKAGES)

The Packages that are the part of java API’s and includes variousclasses, interfaces, sub packages that are already defined in it are in-built packages. These packages are also known as the Predefined packages.

包是Java API的一部分,包括各种类,接口,已在其中定义的子包是内置包。 这些软件包也称为预定义软件包。

There are some packages that exists in java, they are:

Java中存在一些软件包,它们是:

  • java.lang: uses to bundles the fundamental classes.

    java.lang :用于捆绑基本类。

  • java.io: classes for input , output functions are bundled in this package.

    java.io :用于输入,输出功能的类捆绑在此包中。

  • java.util: classes which are implemented in data structure for date and time operations are bundled here.

    java.util :这里捆绑了在数据结构中用于日期和时间操作的类。

  • java.applet: bundles classes for making applets .

    java.applet :捆绑用于制作applet的类。

  • java.net: bundles the classes for supporting network operations.

    java.net :捆绑用于支持网络操作的类。

These all are in-built packages that are commonly used.

这些都是常用的内置软件包。

Java包的优点 (MERITS of packages in java)

  1. By the use of packages in java, it becomes easy to search and locate any class, annotation, enumeration etc.

    通过使用Java中的包,可以轻松地搜索和找到任何类,注释,枚举等。

  2. Naming conflict can be prevented that are occurred in between the different classes by the use of java packages.

    通过使用Java包,可以防止在不同类之间发生命名冲突。

  3. Java packages renders protection.

    Java软件包提供了保护。

  4. Most of programming tasks are done by the API’s classes and Packages, which minimize the number of lines that are written within the piece of code.

    大多数编程任务都是由API的类和包完成的,它们可以最大程度地减少代码段中编写的行数。

  5. Reduction in execution time i.e. execution time is less.

    减少执行时间,即执行时间更少。

  6. Uses less memory space.

    使用更少的内存空间。

  7. Improved performance.

    改进的性能。

Steps for creating a user defined package:

创建用户定义包的步骤:

  1. Package program’s first statement should be the package statement.

    打包程序的第一个语句应为package语句。

  2. Class modifier must we public so that the class and methods can be used outside the program.

    我们必须公开Class修饰符,以便可以在程序外部使用类和方法。

  3. Only one public class or only one public interface are used in package program while any number of normal classes are used in it.

    程序包程序中仅使用一个公共类或仅一个公共接口,而在其中使用了任意数量的普通类。

  4. It should contain any main class not the main () in it.

    它应该包含任何主类,而不是main()。

  5. Constructor modifier must be Public.

    构造函数修饰符必须为Public。

  6. Method modifier of class or interface must be public.

    类或接口的方法修饰符必须是公共的。

  7. The package program should be save either with public class name or a public interface name.

    程序包应使用公共类名或公共接口名保存。

Syntax:

句法:

//Sum.java
//save package with 'public' classname
//first statement is package
package OurPackage
//class modifier must public
public class Sum {
//constructor modifier must public.
Public Sum() {
System.out.println("Sum class constructor");
}
//method modifier must public.
Public void show() {
System.out.println("Sum class method");
}
}

Read more: Packages in Java

: Java包

翻译自: https://www.includehelp.com/java/packages-in-java.aspx

java反射用法示例

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/540593.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[转载] python 元组tuple - python基础入门(14)

参考链接: Python元组Tuple 目录 一.元组tuple定义 二.元组tuple查询 三.元组tuple不支持删除/修改数据 四.元组tuple与列表list的相互转换 五.重点总结 在上一篇文章中我们讲解了关于python列表List的相关内容,今天给大家解释一下列表List的…

MaxCompute 2.0—从ODPS到MaxCompute

从ODPS到MaxCompute-阿里大数据的进化之路是一个商用大数据系统发展史,一个商业大数据系统要解决的问题有可靠性,高性能,安全性等等六个方面。内部产品名ODPS的MaxCompute,是阿里巴巴内部发展的一个高效能、低成本,完全…

python数值类型_Python数值类型

python数值类型In programming, Data Types are an essential concept. Data of various types can be stored in variables as per the task we want the variables to perform. 在编程中,数据类型是必不可少的概念。 根据我们希望变量执行的任务,各种类…

[转载] Python高级变量(列表、元组、字典、字符串、公共方法)

参考链接: Python | 重点数据类型 (字符串,列表,元组,迭代)(String, List, Tuple, Iteration) 文章目录 高级变量类型目标知识点回顾 01. 列表1.1 列表的定义1.2 列表常用操作del 关键字(科普)关键字、函数…

python 操作mongodb数据库参考文档

参考文档链接:https://pypi.python.org/pypi/pymongo pymongo的参考文档http://api.mongodb.com/python/current/tutorial.html mongoengine的参考文档:https://pypi.python.org/pypi/mongoengine#downloads Flask-MongoEngine的参考文档:htt…

php eot eod_EOD的完整形式是什么?

php eot eodEOD:一天结束 (EOD: End Of Day) EOD is an abbreviation of "End Of Day". EOD是“ End Of Day”的缩写 。 It is an expression, which is commonly used in the Gmail platform. In a particular mail, if the sender wants to give the d…

[转载] python元组 tuple

参考链接: Python元组Tuple 类型特点:可以存放多个、 可以重复的,有顺序的数据,数据不可变。 如果项目中需要定义多个数据到一个变量中存放 存放的数据,在项目运行过程中,会发生数据的增加、修改、删除…

aio nio aio_AIO的完整形式是什么?

aio nio aioAIO:多合一 (AIO: All-in-one) AIO is an abbreviation of "all-in-one", which is also known as an MFP (multi-function product/printer/peripheral), multi-functional or multi-function device (MFD). It is a workplace machine that …

[转载] python基础入门二

参考链接: Python集合Set 写代码,有如下变量,请按照要求实现每个功能 (共6分,每小题各0.5分) name ” aleX” 1)移除 name 变量对应的值两边的空格,并输出处理结果 2) 判断 name 变量对应的值是否以 “al” 开头,并输出结果
…

组合数据类型练习,英文词频统计实例上

1、字典实例:建立学生学号成绩字典,做增删改查遍历操作。 建立: d{0001:99,0003:89,0004:98,0005:100,0006:78} 增:d[0002]79 删:d.pop(0001) 改:d[0004]100 查:print(d[0002]) 遍历操作&#x…

茱莉亚分形_茱莉亚的NaN Constant

茱莉亚分形Julia| NaN / Nan64常数 (Julia | NaN/Nan64 Constant) Nan / Nan64 is a constant of the Float64 type in Julia programming language, it represents "not-a-number" value. Nan / Nan64是Julia编程语言中Float64类型的常量,它表示“非数字…

[转载] Python3 数组

参考链接: Python中的Array | 数组1(简介和功能) 一、list和array的区别 Python的数组通过Numpy包的array实现。 Python里二者最大的区别是,list可以存储不同类型的数据,而array只能存储相同类型的数据。 import numpy #直接定义 a […

201671010128 2017-09-24《Java程序设计》之继承

1.继承的概念及理解: 继承是java面向对象编程技术的一块基石,因为它允许创建分等级层次的类。继承就是子类继承父类的特征和行为,使得子类对象(实例)具有父类的实例域和方法,或子类从父类继承方法&#xff…

紫外线的形式是什么?

紫外线:紫外线 (UV: Ultraviolet) UV is an abbreviation of Ultraviolet. In RO water purifiers, the bacteria or germs which are present in the water cannot get killed by reverse osmosis process but this process can banish the dissolved solids and i…

[js高手之路] html5 canvas系列教程 - 掌握画直线图形的常用API

我们接着上文[js高手之路] html5 canvas系列教程 - 认识canvas以及基本使用方法继续. 一、直线的绘制 cxt.moveTo( x1, y1 ): 将画笔移动到x1, y1这个点 cxt.lineTo( x2, y2 ):将画笔从起点开始画直线,一直画到终点坐标( x2, y2 ) cxt.stroke…

金矿问题

Description: 描述: This is a standard interview problem featured in interview coding rounds of Amazon, Flipkart. 这是亚马逊Flipkart的采访编码回合中的标准采访问题。 Problem statement: 问题陈述: Given a gold mine of n*m dimensions, e…

[转载] python中的数组类型及特点

参考链接: Python中的Array | 数组2(简介和功能) 名称 表示方法示例 是否有序 函数方法(增删等) 特点 List 类型表示:L L [Adam, 95.5, Lisa, 85] 有序 增加:(1)L.append(Paul),增加…

puppet

Puppet前期环境(网络、解析、yum源、NTP)在上一章节已经准备就绪,接下来我们就开始安装Puppet了,安装Puppet其实很简单,官方已经提供了yum源,只需要自己将所需要的安装包下载下来然后做成本地yum源即可使用…

[转载] 【数学问题】利用python求解表达式

参考链接: Python 变量 |表达式 |条件和函数 有时候我们会遇到一些很复杂的表达式,或者想要求解某个表达式,但是手动计算的话不但耗时还费精力,我们能不能利用计算机来帮助我们进行计算呢? 1…

cesium广告牌_公路广告牌

cesium广告牌Description: 描述: This is a standard dynamic programing problem of finding maximum profits with some constraints. This can be featured in any interview coding rounds. 这是在某些约束条件下找到最大利润的标准动态编程问题。 这可以在任何…