안드로이드 개발 질문/답변
(글 수 358)
안녕하세요.
개인적으로는 게임에서 자료를 저장할 때,
FileOutputStream fos = null;
ObjectOutputStream oos = null;
String NAME = "아무개";
byte CLASS = 2;
int HP = 123;
int MP = 456;
ArrayList anylist = new ArrayList();
anylist.add(NAME);
anylist.add(CLASS);
anylist.add(HP);
anylist.add(MP);
try {
fos = new FileOutputStream("save");
oos = new ObjectOutputStream(fos);
oos.writeObject(anylist);
oos.flush();
} catch (Exception e) {
System.out.println("에러 : " e);
} finally {
try{
if(oos != null) oos.close();
if(fos != null) fos.close();
} catch (Exception e) {}
}
이런식으로 타입을 지정하지 않은 어레이리스트에 모든 변수를 집어 넣은 후, 그냥 하나의 파일로 쓰는 방식을 사용하고 있습니다. 그런데, 아무래도 JAVA 에서 raw type 이라고 워닝을 막 띄어서 불안한데 보통은 타입이 다른 변수들을 저장할때 어떻게 저장하나요?
그래서 제네릭이 있는거에요