日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java scanner怎么用_Java Scanner delimiter()用法及代码示例

發(fā)布時間:2025/3/20 java 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java scanner怎么用_Java Scanner delimiter()用法及代码示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

java.util.Scanner類的delimiter()方法返回此Scanner當前用于匹配定界符的Pattern。

用法:

public Pattern delimiter()

返回值:該函數(shù)返回掃描儀的定界圖案。

以下示例程序旨在說明上述功能:

示例1:

// Java program to illustrate the

// delimiter() method of Scanner class in Java

import java.util.*;

public class GFG1 {

public static void main(String[] argv)

throws Exception

{

String s = "Geeksforgeeks has Scanner Class Methods";

// create a new scanner

// with the specified String Object

Scanner scanner = new Scanner(s);

// prints the next line of the string

System.out.println("Scanner String: \n"

+ scanner.nextLine());

// print the delimiter this scanner is using

System.out.println("\nDelimiter being used in Scanner: "

+ scanner.delimiter());

// Close the scanner

scanner.close();

}

}

輸出:

Scanner String:

Geeksforgeeks has Scanner Class Methods

Delimiter being used in Scanner: \p{javaWhitespace}+

示例2:

// Java program to illustrate the

// delimiter() method of Scanner class in Java

import java.util.*;

public class GFG1 {

public static void main(String[] argv)

throws Exception

{

String s = "Geeksforgeeks.has.Scanner.Class.Methods";

// create a new scanner

// with the specified String Object

Scanner scanner = new Scanner(s);

// Set the delimiter to "."

scanner.useDelimiter(".");

// prints the next line of the string

System.out.println("Scanner String: \n"

+ scanner.nextLine());

// print the delimiter this scanner is using

System.out.println("\nDelimiter being used in Scanner: "

+ scanner.delimiter());

// Close the scanner

scanner.close();

}

}

輸出:

Scanner String:

Geeksforgeeks.has.Scanner.Class.Methods

Delimiter being used in Scanner: .

總結

以上是生活随笔為你收集整理的java scanner怎么用_Java Scanner delimiter()用法及代码示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。