שאלה ב- JAVA

ShayHk

New member
שאלה ב- JAVA

יצרתי משתנה String ואתחלתי אותו איך אפשר להכניס לאיבר ה-I אות כלשהי במקום String x("abcd"); // x[2]='Z'; ??? איך
 

IP yuval

New member
אם אני לא טועה, אתה לא יכול לשנות

מחרוזות. כדאי לך להשתמש במערך במקום.
 

EndersG

New member
לא הכי יעיל אבל עושה את העבודה

במקום String תשתמש בStringBuffer יש לו מתודה
StringBuffer replace(int start, int end, String str) Replaces the characters in a substring of this StringBuffer with characters in the specified String.​
וגם את המתודה:
String substring(int start) Returns a new String that contains a subsequence of characters currently contained in this StringBuffer.The substring begins at the specified index and extends to the end of the StringBuffer.​
ואידך זיל גמור
 

DadleFish

New member
גם לעבוד עם JAVA באופן כללי

זה מאוד לא יעיל
ובכל מקרה, מה הפתרון האידיאלי?
 
למעלה