java scanner

扫描器类match()方法 (Scanner Class match() method)

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

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

  • match() method is used to get the MatchResult of the last scanning operation operated by this Scanner.

    match()方法用于获取此Scanner上次操作的MatchResult。

  • match() 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.

    match()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • match() method may throw an exception at the time of returning MatchResult. IllegalStateException: This exception may throw when none match result exists.

    match()方法在返回MatchResult时可能会引发异常。 IllegalStateException :如果不存在匹配结果,则可能引发此异常。

Syntax:

句法:

    public MatchResult match();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is MatchResult, it gets match result for the last matching operation.

该方法的返回类型为MatchResult ,它获取上一次匹配操作的匹配结果。

Example:

例:

// Java program to demonstrate the example
// of MatchResult match() method of Scanner
import java.util.*;
public class MatchOfScanner {public static void main(String[] args) {String str = "Hi, [IncludeHelp] +\n 10.0 true ";
// Instantiates a Scanner object with
// the given string str
Scanner sc = new Scanner(str);
// Display str
System.out.println("sc.nextLine(): " + sc.nextLine());
// By using match() method is
// to match the last scanning
// operation performed by this Scanner
System.out.println("sc.match(): " + sc.match());
// By using close() method is to
// close the Scanner object
sc.close();
}
}

Output

输出量

sc.nextLine(): Hi, [IncludeHelp] +
sc.match(): [email protected]

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

java scanner

java scanner_Java Scanner match()方法与示例相关推荐

  1. java的scanner的方法_Java Scanner reset()方法

    Java Scanner reset()方法 java.util.Scanner.reset() 方法重置该扫描仪.重设scanner 丢弃所有的这些可能已被useDelimiter(java.uti ...

  2. java散列法的运用实例,Java HashMap compute() 使用方法及示例

    Java HashMap compute() 使用方法及示例 Java HashMap compute()方法计算一个新值,并将其与哈希映射中的指定键相关联. compute()方法的语法为: has ...

  3. math的用法在java中的使用,Java Math cbrt() 使用方法及示例

    Java Math cbrt() 使用方法及示例 Java Math cbrt()方法返回指定数字的立方根. cbrt()方法的语法为: Math.cbrt(double num) 注意:cbrt() ...

  4. java arraylist 方法返回值,Java ArrayList get() 使用方法及示例

    Java ArrayList get() 使用方法及示例 Java ArrayList get()方法返回指定位置存在的元素. get()方法的语法为: arraylist.get(int index ...

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

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

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

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

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

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

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

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

  9. java kryo_Kryo框架使用方法代码示例

    Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...

最新文章

  1. 【CCIE学习干货】LDP:标签的那些事儿
  2. C语言实现常用数据结构——队列
  3. WEBGIS体系和OGC标准
  4. 【操作系统】实验 模拟操作系统的文件管理系统
  5. linux内存管理总结
  6. ubuntu16.04源码编译安装nginx1.16.2
  7. dvm与art的区别_Android运行时– DVM与ART,AOT与JIT
  8. CentOS 6.3 编译安装搭建LNMP(迎接端午节,首发)
  9. WCF编程]WCF使用Net.tcp绑定时候出现错误:元数据包含无法解析的引用
  10. android入门级智能手表产地,从全球智能手表市场来看,Android智能手表只在中国卖得好...
  11. Java中静态代码块、构造代码块的区别
  12. 详解各种光学仪器成像原理
  13. ML-Agents训练智能AI使用技巧
  14. SLG变现强劲,却易遭黑产侵袭,如何破局?SLG游戏安全方案定制做到出奇制胜!
  15. new date的含义
  16. [Android] 该文件包与具有同一名称的现有文件包存在冲突
  17. 电脑英语Computer English
  18. 如何在 SubSystem for Android 上安装应用?
  19. mysql 13位时间戳转时间戳_时间戳换算(13位时间戳转换工具 在线)
  20. Android下载图片并添加图片水印

热门文章

  1. axure原件 总是丢失_Axure实现提示文本单击显示后自动消失的效果
  2. 玩转linux文件描述符和重定向,玩转Linux文件描述符和重定向
  3. javascript字典中添加数组_如何在 JavaScript 中更好地使用数组
  4. python爬电影_使用Python多线程爬虫爬取电影天堂资源
  5. python字符串前面加f什么意思_Python 字符串前面加u,r,b,f的含义
  6. dhcp只能分配与路由器相同网段么_路由器的桥接详解
  7. 性能测试总结(一)---基础理论篇(转载)
  8. Centos 7初始化脚本
  9. MySQL定义数据库对象之指定definer
  10. 李洪强iOS开发之FMDB线程安全的用法