---
title: "数组小例子"
author: "Roger111"
date: "2012-06-19T22:21:32Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2012-06-19T22:21:32Z"
id: 1564264
url: "https://rogerming.iteye.com/blog/1564264"
---

```
public class ArrayTest {
	private String[] cc = new String[0];
	
	public void addCC(String ss){
		String temp[] = new String[cc.length+1];
		for(int i=0;i<cc.length;i++)
			temp[i] = cc[i];
		temp[cc.length] = ss;
		cc = temp;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArrayTest sg = new ArrayTest();
		sg.addCC("gouhuo");
		sg.addCC("xunyou");
		sg.addCC("xiayu");
		
		int l = sg.cc.length;
		System.out.println(l);
		for(int i=0;i<l;i++){
			System.out.println(sg.cc[i]);
		}
	}

}
```