Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
javaのインデックス番号に基づいて残りの文字列を削除する方法はありますか?
いくつかの理由により、replace() または split() は使用できません。分割したい場所のインデックスを見つけることができました。それを実現するための効果的な方法を見つける必要があります。何も組み込まれていない場合は、ループを使用する必要があると思います。
どんなフィードバックでも大歓迎です!
String#substringを使用できます:
s.substring(0, index);
これにより、インデックスまでの文字列が得られます (ただし、インデックスは含まれません)。