阅读背景:

将一个字符串拆分成一个要再次调用的字数组

来源:互联网 

This is my code so far below

这是我目前的代码

import java.util.*;
import java.io.*;
public class USconstitution   
{
  public static void main(String [] args) throws Exception
  {
     Scanner inFile = new Scanner(new File("constitution.txt"));
     int x = 0;
     int keyword1 = 0;
     Scanner keyboard = new Scanner(System.in);
     System.out.println("Enter a word from the keyboard");
     String input = keyboard.next();
     while(inFile.hasNext())
     {
        String word = inFile.next();
        x++;
        if(input.equalsIgnoreCase(word))
           keyword1++;
     }
     //System.out.println("\n" + x);
     System.out.println("The constitution has " + x + " words");
     System.out.println("The first keyword shows up " + keyword1 + " times in the  

     constitution");
  }
}
impor



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: