Contains
This method is part of the solution to an assignment given
out in the fall of 2003. Here is the description of the
method as given in the assignment:
Download files: Contains.java
Areas: Introduction to loops.
/**
* Return whether s contains every letter in t. For example,
* "abcd" contains all the letters in "bbdc", since every letter
* in the second String appears in the first.
* Precondition: s != null && t != null.
*/
public static boolean contains(String s, String t)
* Return whether s contains every letter in t. For example,
* "abcd" contains all the letters in "bbdc", since every letter
* in the second String appears in the first.
* Precondition: s != null && t != null.
*/
public static boolean contains(String s, String t)
Download files: Contains.java
Areas: Introduction to loops.
|
|
Contains.java |
|
View full source |
| Question 1 |
| When this method returns, the variable contains has the obvious meaning: it is true if and only if s contains every letter of t. What is the meaning of contains when tested at the top of the for-loop on line 9, while i=n and t.length()>n? |
