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
scanner close_Java Scanner close()方法与示例相关推荐
- java scanner_Java Scanner nextLong()方法与示例
java scanner 扫描器类的nextLong()方法 (Scanner Class nextLong() method) Syntax: 句法: public long nextLong(); ...
- java scanner_Java Scanner skip()方法与示例
java scanner 扫描仪类skip()方法 (Scanner Class skip() method) Syntax: 句法: public Scanner skip(Pattern patt ...
- java scanner_Java Scanner match()方法与示例
java scanner 扫描器类match()方法 (Scanner Class match() method) match() method is available in java.util p ...
- java scanner_Java Scanner radix()方法与示例
java scanner 扫描器类radix()方法 (Scanner Class radix() method) radix() method is available in java.util p ...
- Java Scanner next()方法与示例
扫描仪类的next()方法 (Scanner Class next() method) Syntax: 句法: public String next(); public String next(Pat ...
- Java Scanner nextLine()方法与示例
扫描仪类nextLine()方法 (Scanner Class nextLine() method) nextLine() method is available in java.util packa ...
- java scanner_Java Scanner nextDouble()方法与示例
java scanner 扫描仪类的nextDouble()方法 (Scanner Class nextDouble() method) nextDouble() method is availabl ...
- Java Scanner findInLine()方法与示例
扫描仪类findInLine()方法 (Scanner Class findInLine() method) Syntax: 句法: public String findInLine(Pattern ...
- java fileoutputstream close_Java FileOutputStream close()方法与示例
FileOutputStream类close()方法close()方法在java.io包中可用. close()方法用于关闭此FileOutputStream并释放与此流链接的所有系统资源. clos ...
最新文章
- Windows域信任关系建立全攻略
- ecshop管理找不到index.php,前台出现找不到这样的目录,打不开某文件的提示
- HDU4633(Polya计数)
- Java基本数据类型及所占字节大小
- 可以闭眼入的O'REILLY机器学习神书出新版了!
- OFDM简介--OFDM的发送(1)
- 小米红米有锁机如何刷机升级MIUI12.5系统-完美解锁机刷机教程
- 第三方支付api接口是什么?
- 三年精进笃行,用友YonSuite“数智飞轮”高速运转起来了!
- 【华为OD机试真题 Python】判断字符串子序列
- android xml alpha,xml - Android和设置alpha(imageview alpha
- MUR1060AC-ASEMI快恢复二极管10A 600V
- 明确工作职责的重要性
- 分割(Partition)
- Lesson Forty-Seven A cup of coffee. 一杯咖啡.
- 基于C#平台下利用POP3和SMTP协议的邮件归档系统
- C#,哈夫曼编码(Huffman Code)压缩(Compress )与解压缩(Decompress)算法与源代码
- Clickhouse—MergeTree 数据生命周期
- fastadmin哪里看php版本,fastadmin-tp6
- PSobj [4]裂痕