1. 程式人生 > >新人初學java,想請大佬們分享一下學習經驗!

新人初學java,想請大佬們分享一下學習經驗!

Write a method that searchs for a specific string within another string; the method must return true if the former exists in the latter string. For example: isSubString(“cat”, “The cat in the hat.”) is true, but isSubString(“bat”, “The cat in the hat.”) is false. Also, verify that the boundry conditions are also met. Also, verify that the boundry conditions are also met: isSubString(“The”, “The cat in the hat.”) is true isSubString(“hat.”, “The cat in the hat.”) is true

Hint - Use the charAt(int index) method in the String class to retrieve a specific character from a string; the index starts with zero. For example. “cat”.charAt(0) is c', "cat".charAt(1) isa’, and “cat”.charAt(2) is `t’. The length method returns the number of characters in the string; e.g. “cat”.length() is 3.

不能直接使用java裡面的類包,需要自己申明方法。