PROGRAMMING:Count the frequency of keyword in Java program
Write a program to count the number of keywords (case sensitive) in an input java source code. The explanation is as follows:
*There are 53 keywords in Java (Baidu)
*Input a section of source code from the keyboard, and count the number of keywords in this section of source code
*There is no need to count the keywords in the comments
*The keywords in the string are not counted
*The keywords and quantity are sorted and output in ascending order
*If the source code is not input, the input is considered illegal
###Input format:
Input java source string, one or more lines, with the 'exit' line as the end flag
###Output format:
*When the source code is not input, the program outputs ` wrong format`
*When there are no statistics, the output is empty
*When there is statistical data, the keywords are arranged in ascending order. Each row outputs a keyword and quantity in the format of quantity keyword`
###Input example:
Here is a set of inputs. For example:
```in
//Test public method
public HashMap(int initialCapacity) {
this(initialCapacity, DEFAULT_ LOAD_ FACTOR);
}
public HashMap(int initialCapacity, float loadFactor) {
if (initialCapacity < 0)
throw new IllegalArgumentException("Illegal initial capacity: " +
initialCapacity);
if (initialCapacity > MAXIMUM_ CAPACITY)
initialCapacity = MAXIMUM_ CAPACITY;
if (loadFactor <= 0 || Float.isNaN(loadFactor))
throw new IllegalArgumentException("Illegal load factor: " +
loadFactor);
this.loadFactor = loadFactor;
this.threshold = tableSizeFor(initialCapacity);
}
exit
```
###Output example:
The corresponding output is given here. For example:
```out
one float
three if
two int
two new
two public
three this
two throw
```
answer:If there is no answer, please comment
The title must use one or more of list, set or map. If the above interface is not used at all, no score will be given
*There are 53 keywords in Java (Baidu)
*Input a section of source code from the keyboard, and count the number of keywords in this section of source code
*There is no need to count the keywords in the comments
*The keywords in the string are not counted
*The keywords and quantity are sorted and output in ascending order
*If the source code is not input, the input is considered illegal
###Input format:
Input java source string, one or more lines, with the 'exit' line as the end flag
###Output format:
*When the source code is not input, the program outputs ` wrong format`
*When there are no statistics, the output is empty
*When there is statistical data, the keywords are arranged in ascending order. Each row outputs a keyword and quantity in the format of quantity keyword`
###Input example:
Here is a set of inputs. For example:
```in
//Test public method
public HashMap(int initialCapacity) {
this(initialCapacity, DEFAULT_ LOAD_ FACTOR);
}
public HashMap(int initialCapacity, float loadFactor) {
if (initialCapacity < 0)
throw new IllegalArgumentException("Illegal initial capacity: " +
initialCapacity);
if (initialCapacity > MAXIMUM_ CAPACITY)
initialCapacity = MAXIMUM_ CAPACITY;
if (loadFactor <= 0 || Float.isNaN(loadFactor))
throw new IllegalArgumentException("Illegal load factor: " +
loadFactor);
this.loadFactor = loadFactor;
this.threshold = tableSizeFor(initialCapacity);
}
exit
```
###Output example:
The corresponding output is given here. For example:
```out
one float
three if
two int
two new
two public
three this
two throw
```
answer:If there is no answer, please comment
The title must use one or more of list, set or map. If the above interface is not used at all, no score will be given