Home Java Java-conversion Changing the value of Array in Java



Changing the value of Array in Java
Posted on: June 25, 2008 at 12:00 AM
This is very simple of one dimensional array program. In this tutorial you will learn how to change array values. The one dimensional array program is provided Java application program about the explanation with Java Source code.

Changing the Value of Array in Java

     

This is very simple of one dimensional array program. In this tutorial you will learn how to change array values. The one dimensional array program is provided Java application program about the explanation with Java Source code. 

Here we are going to make a program to follows the one dimensional array program. In  this program firstly we are going to define class "ArrayExchange" .Now we have to make a two integer value for array1 and array2. After that in this program we are going to using for loop for array1.length. This program take array type number. We are going to pass array values array2 to array1then display the massage array1 values array2.

Here is the code of this program:

public class CopyArray {
  public static void main(String[] args) {
  int array1[]{2,3,4,5,8,9};
  int array2[] new int[6];
  System.out.println("array:")
  System.out.print("[");
  for (int i=0; i<array1.length; i++){
  System.out.print(" "+array1[i]);
  }
  System.out.print("]");
  System.out.println("\narray1:");
  System.out.print("[");
  for(int j=0; j<array1.length; j++){
  array2[j= array1[j];
  System.out.print(" "+ array2[j]);
  }
  System.out.print("]");
  }
}

Download this Example

Related Tags for Changing the value of Array in Java:
javacidearrayapplicationiovitutorialvaluesourcechangeriathisidappsimplewithprogramnatvaluestolearnramlaneareilitlihangimceinmoutcajesexplanationplanrcmehowproppcattorssoatishaimellmplraydimensioneaarcodcodesimxpvatutorssrithavabatiapaludimensionalicaicapleplprodeonogro


More Tutorials from this section

Ask Questions?    Discuss: Changing the value of Array in Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.