Skip to content

Instantly share code, notes, and snippets.

@ron623
Created March 7, 2015 04:02
Show Gist options
  • Save ron623/8f0fc7b46a18742c36b4 to your computer and use it in GitHub Desktop.
Save ron623/8f0fc7b46a18742c36b4 to your computer and use it in GitHub Desktop.
no5
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