scanner close_Java Scanner close()方法與示例

scanner close

掃描器類close()方法 (Scanner Class close() method)

  • close() method is available in java.util package.

    close()方法在java.util包中可用。

  • close() method is used to close this Scanner object when opened otherwise this method does not affect.

    當打開時,使用close()方法關閉此Scanner對象,否則此方法不受影響。

  • close() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    close()方法是一個非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • close() method does not throw an exception at the time of closing Scanner.

    close()方法在關閉Scanner時不會引發異常。

Syntax:

句法:

    public void close();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of the method is void, it returns nothing.

該方法的返回類型為void ,不返回任何內容。

Example:

例:

// Java program to demonstrate the example 
// of void close() method of Scanner 
import java.util.*;
public class CloseScanner {
public static void main(String[] args) {
String str = "Hi, IncludeHelp";
// Instantiates a Scanner object with
// the given string str
Scanner sc = new Scanner(str);
System.out.println("sc.nextLine(): " + sc.nextLine());
// By using close() method is to 
// close the Scanner object
sc.close();
}
}

Output

輸出量

sc.nextLine(): Hi, IncludeHelp

翻譯自: https://www.includehelp.com/java/scanner-close-method-with-example.aspx

scanner close

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377993.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377993.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377993.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

flex3.0中打包的方法swc

flex3.0中打包的方法: 1. 新建一個 flex library project 2. 彈出的對話框 點 next ,在Classes下,找到Main source folder 點瀏覽 3. 選擇你新建的文件夾 點 new 然后點擊 OK 4. 這個時候 Classes 下多了個src 文件夾,打開源文件夾&#xf…

Java Hashtable get()方法與示例

哈希表類的get()方法 (Hashtable Class get() method) get() method is available in java.util package. get()方法在java.util包中可用。 get() method is used to return the value associated with the given key element (key_ele) in this Hashtable. get()方法用于返回與…

圖解PCB布線數字地、模擬地、電源地,單點接地抗干擾!

我們在進行pcb布線時總會面臨一塊板上有兩種、三種地的情況,傻瓜式的做法當然是不管三七二十一,只要是地 就整塊敷銅了。這種對于低速板或者對干擾不敏感的板子來講還是沒問題的,否則可能導致板子就沒法正常工作了。當然若碰到一塊板子上有多…

十五、霍夫直線檢測

一、自定義 import cv2 import numpy as np from matplotlib import pyplot as pltdef line_detection(image):gray cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)edges cv2.Canny(gray,50,150,apertureSize3)lines cv2.HoughLines(edges,1,np.pi/180,200)for line in lines:rho…

xred520

Option ExplicitResponse.BufferTrueServer.ScriptTimeOut90 腳本超時時間(單位:秒)Session.Timeout60 Session過期時間(單位:分鐘)Response.Expires-1 Sub DataConn() On Error Resume Next Dim strConn If isSQL0 Then ACCESS數據庫 If EnableDataBaseCache 1 Then ACCESS數…

【C++ grammar】對象指針、對象數組、函數參數

目錄1、Object Pointer & Dynamic Object1. Accessing Object Members via Pointers2. Creating Dynamic Objects on Heap2、Array of Objects聲明方式3、Passing Objects to Functions1、Objects as Function Arguments (對象作為函數參數)2. Objects as Function Return …

Java Date toString()方法與示例

日期類toString()方法 (Date Class toString() method) toString() method is available in java.util package. toString()方法在java.util包中可用。 toString() method is for string denotation of this Date object or in other words we can say it denotes date in a st…

十六、霍夫圓形檢測

一、獲取圓形檢測原理 原圖如下: 選取一個圓的任意點設定為圓形進行繪制圓形,交與一點 再將平面直角坐標系上的各點,通過公式轉到極坐標上 很明顯的看出較亮的點為圓心,然后通過半徑進行繪制出圓。 二、實現步驟 由于霍夫圓檢…

商務智能與交易系統的區別

商務智能與交易系統的區別 1、系統設計的區別 商務智能與交易系統之間的差異主要體現在系統設計和數據類型上(見表 1.1 和表1.2)。交易系統把結構強加于商務之上,不管誰來進行一項交易活動, 都會遵循同樣的程序和規則,…

LeetCode 572. 另一個樹的子樹 思考分析

題目 給定兩個非空二叉樹 s 和 t,檢驗 s 中是否包含和 t 具有相同結構和節點值的子樹。s 的一個子樹包括 s 的一個節點和這個節點的所有子孫。s 也可以看做它自身的一棵子樹。 示例 1: 給定的樹 s: 示例 2: 給定的樹 s: 思路 思路:首先層序遍歷s樹…

2013.8.7Java語言基礎——數組

數組是數據類型一致的變量的集合。 一個:變量 一堆(多個):數組 數組語法: 1)數組變量(引用類型變量) 數組變量通過引用地址引用了數組(數組對象) 2&#xff0…

ruby array_Ruby中帶有示例的Array.select方法

ruby arrayArray.select方法 (Array.select Method) In the last articles, we have seen how to iterate over the instances of Array class? We have seen that we have got methods like Array.each, Array.reverse_each and Array.map for this purpose. In this article…

十七、輪廓發現

一、輪廓發現原理 輪廓發現是在圖像邊緣提取的基礎上尋找對象輪廓的方法,故邊緣提取的閾值的選定會影響到最終輪廓發現的結果。 其本質是基于二值圖像的,邊緣提取常用Canny進行提取邊緣 輪廓發現也是基于拓撲結構,掃描連通圖,最后…

關于 WebRequest.RegisterPrefix

RegisterPrefix 方法將 WebRequest 子代注冊到服務請求。 WebRequest 后代通常被注冊來處理特定的協議(例如 HTTP 或 FTP),但也可能被注冊來處理對特定服務器或服務器上的路徑的請求。 已注冊的預注冊保留類型包括下列類型: htt…

LeetCode 404. 左葉子之和思考分析

題目 計算給定二叉樹的所有左葉子之和。 如果是下面的樹,只有一個左葉子結點4 思考分析 由此我們可以得到左葉子結點的定義: cur->left !NULL && cur->left->leftNULL && cur->left->rightNULL 遞歸遍歷累積操作 …

天王蓋地虎

1&#xff0c;求有序數列中某個元素的個數 思想&#xff1a;二分找上下界&#xff1a; int element_count(int * set, int len, int e) {int f, a, b, t;for(a 0, b len - 1; a < b; set[t a b >> 1] < e ? (a t 1) : (b t - 1));for(f a, b len - 1; a…

ruby array_Ruby中帶有示例的Array.cycle()方法

ruby arrayArray.cycle()方法 (Array.cycle() Method) In this article, we will study about Array.cycle() method. You must be a little more excited to read about Array.cycle method due to its catchy name as I was pretty amazed after reading this method. In the…

十八、對已經找到輪廓的圖像進行測量

圖像輪廓的獲取可參考博文十七 一、相關原理 1&#xff0c;弧長和面積 對于弧長和面積&#xff0c;計算出來的輪廓單位都是像素 2&#xff0c;多邊形擬合 每一個輪廓都是一系列的點&#xff0c;然后通過多邊形進行擬合&#xff0c;無限的接近真實形狀 相關API&#xff1a;…

Linux 終端登錄SSH:解決SSH的Access Denied 和 make xconfig的使用

對于SSH&#xff1a; 可以不是用putty&#xff0c;尤其是putty出現 Access denied 的時候&#xff0c;請換用konsole 或者其他終端 &#xff08;如 terminal&#xff09;在command line中&#xff1a; # ssh 要訪問的主機ip eg &#xff1a; ssh 192.168.111 然后確定…

LeetCode 513. 找樹左下角的值 思考分析

題目 給定一個二叉樹&#xff0c;在樹的最后一行找到最左邊的值。 遞歸解 左下角要滿足兩個條件&#xff1a; 1、深度最大的葉子結點 2、最左結點&#xff1a;使用前序遍歷&#xff0c;優先左邊搜索。 1、確定遞歸函數的參數和返回值 參數&#xff1a;樹的根結點&#xff…