-
-
Save ron623/8f0fc7b46a18742c36b4 to your computer and use it in GitHub Desktop.
no5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package study_03; | |
public class No5 { | |
/* | |
* 指定されたindexから始まる部分文字列の先頭から始まるかどうかテストする | |
* | |
* このオブジェクトの部分文字列のときはtrue,そうでなければfalse | |
* tooffsetが負の値である場合、あるいはStringオブジェクトの長さよりも長い場合false そうでない場合は結果は次の式の結果と同じ | |
* this.subString(toffset).startsWith(prefix) | |
*/ | |
public boolean startsWith(String prefix, int toffset) { | |
// Stringオブジェクト | |
char ta[] = value; | |
// toffset(文字列の長さ) | |
int to = toffset; | |
// TODO:③ | |
//char pa[] = XXX | |
int po = 0; | |
int pc = prefix.value.length; | |
// tooffsetが 負の値 or Stringオブジェクトの長さよりも長い場合 | |
if (( toffset < 0 ) || (toffset > value.length -pc)){ | |
// TODO:① | |
//return false; | |
} | |
while (equals(--pc >= 0)) { | |
// TODO:② | |
if(ta[to++] != XXX){ | |
return false; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment