http://www.verejava.com/?id=16992650730025
/*
数组分类
1. 一维数组
	1.1 一维数组的定义和初始化
	1.2 对一维数组的操作, 遍历,添加,插入,修改,删除,排序,查找
2. 二维数组
	2.1 二维数组的定义和初始化
	2.2 二维数组的遍历
3. 多维数组
4. 增强for循环
*/
public class ArrayAppend
{
	public static void main(String[] args)
	{
		//一维数组的定义和初始化
		//静态定义一维数组
		int[] scores={90,70,50,80,60,85};
		
		
		//向一维数组scores末尾中添加一个学生的成绩 75.
		/*
		思路:
			1. 先创建一个比原来scores数组长度大1的临时数组 tempArray
			2. 将scores数组的每一个值复制到 tempArray
			3. 然后将 成绩为 75 赋值到 tempArray的新增最后的索引位置
			4. 最后将tempArray地址指针引用赋值给 scores;
		*/
		int[] tempArray=new int[scores.length+1];
		for(int i=0;i<scores.length;i++)
		{
			tempArray[i]=scores[i];
		}
		tempArray[scores.length]=75;
		scores=tempArray;
		//打印输出添加75成绩后的scores
		for(int i=0;i<scores.length;i++)
		{
			System.out.print(scores[i]+",");
		}
	}
}
                  
                  
                  
                  
                            
                            
本文详细介绍了在一维数组中如何进行添加元素的操作,并通过具体示例演示了如何将新的元素添加到已存在的数组末尾。文章包括了一维数组的定义、初始化及扩展数组的具体步骤。
          
      
          
                
                
                
                
              
                
                
                
                
                
              
                
                
              
            
                  
					1691
					
被折叠的  条评论
		 为什么被折叠?
		 
		 
		
    
  
    
  
            


            