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.pswp.cn/news/540593.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/540593.shtml
英文地址,請注明出處:http://en.pswp.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. 這是在某些約束條件下找到最大利潤的標準動態編程問題。 這可以在任何…