⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delimiterdemo.java

📁 java编程代码
💻 JAVA
字号:

import java.util.Scanner;

public class DelimiterDemo
{
    public static void main(String[] args)
    {
        Scanner keyboard1 = new Scanner(System.in);
        Scanner keyboard2 = new Scanner(System.in);
        keyboard2.useDelimiter("##");
        //Delimiter for keyboard1 is whitespace.
        //Delimiter for keyboard2 is ##.


        String word1, word2;
        System.out.println("Enter a line of text:");
        word1 = keyboard1.next( );
        word2 = keyboard1.next( );
        System.out.println("For keyboard1 the two words read are:"); 
        System.out.println(word1);
        System.out.println(word2);
        String junk = keyboard1.nextLine( ); //To get rid of rest of line.

        System.out.println("Reenter the same line of text:");
        word1 = keyboard2.next( );
        word2 = keyboard2.next( );
        System.out.println("For keyboard2 the two words read are:"); 
        System.out.println(word1);
        System.out.println(word2);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -