안녕하세요 선후입니다.^^

제가 for문을 쓸려고하는데요 어렵네요


String str = "";
String spaceStr1 = "hello";
String spaceStr2 = "bye";
String spaceStr3 = "see you";

이렇게 뒤에 숫자가 붙은 인스턴스 들이 있는데요
for(int i = 0; i <= 3; i++){
     str += "a" + spaceStr  i  ;
}

여기서 빨간색 i를 넣어서
spaceStr1
spaceStr2
spaceStr3

for문에서 알아서 str에 넣어지게 하고 싶은데요

i를 어떻게 써야하나요 ㅠㅠ?

spaceStr'i' 이렇게 하면 안되더라구요




ex)
String score1 = textScore3.getNodeValue();

여기에서 이렇게 대입하는 것인 아니라.

int i = 3;
String score1 = textScorei.getNodeValue();

3대신에 i를 넣어서 쓸수는 없는지 궁금합니다.^^
profile