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()方法与示例相关推荐

  1. java scanner_Java Scanner nextLong()方法与示例

    java scanner 扫描器类的nextLong()方法 (Scanner Class nextLong() method) Syntax: 句法: public long nextLong(); ...

  2. java scanner_Java Scanner skip()方法与示例

    java scanner 扫描仪类skip()方法 (Scanner Class skip() method) Syntax: 句法: public Scanner skip(Pattern patt ...

  3. java scanner_Java Scanner match()方法与示例

    java scanner 扫描器类match()方法 (Scanner Class match() method) match() method is available in java.util p ...

  4. java scanner_Java Scanner radix()方法与示例

    java scanner 扫描器类radix()方法 (Scanner Class radix() method) radix() method is available in java.util p ...

  5. Java Scanner next()方法与示例

    扫描仪类的next()方法 (Scanner Class next() method) Syntax: 句法: public String next(); public String next(Pat ...

  6. Java Scanner nextLine()方法与示例

    扫描仪类nextLine()方法 (Scanner Class nextLine() method) nextLine() method is available in java.util packa ...

  7. java scanner_Java Scanner nextDouble()方法与示例

    java scanner 扫描仪类的nextDouble()方法 (Scanner Class nextDouble() method) nextDouble() method is availabl ...

  8. Java Scanner findInLine()方法与示例

    扫描仪类findInLine()方法 (Scanner Class findInLine() method) Syntax: 句法: public String findInLine(Pattern ...

  9. java fileoutputstream close_Java FileOutputStream close()方法与示例

    FileOutputStream类close()方法close()方法在java.io包中可用. close()方法用于关闭此FileOutputStream并释放与此流链接的所有系统资源. clos ...

最新文章

  1. Windows域信任关系建立全攻略
  2. ecshop管理找不到index.php,前台出现找不到这样的目录,打不开某文件的提示
  3. HDU4633(Polya计数)
  4. Java基本数据类型及所占字节大小
  5. 可以闭眼入的O'REILLY机器学习神书出新版了!
  6. OFDM简介--OFDM的发送(1)
  7. 小米红米有锁机如何刷机升级MIUI12.5系统-完美解锁机刷机教程
  8. 第三方支付api接口是什么?
  9. 三年精进笃行,用友YonSuite“数智飞轮”高速运转起来了!
  10. 【华为OD机试真题 Python】判断字符串子序列
  11. android xml alpha,xml - Android和设置alpha(imageview alpha
  12. MUR1060AC-ASEMI快恢复二极管10A 600V
  13. 明确工作职责的重要性
  14. 分割(Partition)
  15. Lesson Forty-Seven A cup of coffee. 一杯咖啡.
  16. 基于C#平台下利用POP3和SMTP协议的邮件归档系统
  17. C#,哈夫曼编码(Huffman Code)压缩(Compress )与解压缩(Decompress)算法与源代码
  18. Clickhouse—MergeTree 数据生命周期
  19. fastadmin哪里看php版本,fastadmin-tp6
  20. PSobj [4]裂痕

热门文章

  1. mysql 短时大连接的问题_mysql长连接和短连接的问题
  2. java 拉起服务_技术开发者应该如何构建小团队的微服务方案?
  3. java arraylist 重复_Java中ArrayList去除重复元素
  4. scss-字符串连接符
  5. scss-@for 指令
  6. 腾讯Node.js基础设施TSW正式开源
  7. layui 子页面写弹出框覆盖父页面,以及给弹框中的表单赋值
  8. 从分布式锁角度理解Java的synchronized关键字
  9. 《你的灯亮着吗?》个人总结
  10. mysql慢查询工具