Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Comparing Arrays : Java Util

                         

This section show you how to determine the given arrays are same or not. The given program illustrates you how to compare arrays according to the content of the that.

In this section, you can see that the given program initializes two arrays and input five number from user through the keyboard. And then  the program checks whether the given taken both arrays are same or not. This comparison operation is performed by using the equals() method of Arrays class.

Arrays.equals():
Above method compares two arrays.

Arrays is the class of the java.util.*; package. This class and it's methods are used for manipulating arrays.

Here is the code of the program:

import java.io.*;
import java.util.*;

public class ComparingArrays{
  public static void main(String[] argsthrows IOException{
    int[] array1 = new int[5];
    int[] array2 = new int[5];
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    try{
      System.out.println("Enter 5 numbers for the first Array : ");
      for(int i = 0; i < array1.length; i++){
        array1[i= Integer.parseInt(in.readLine());
      }
      System.out.println("Enter 5 numbers for the second Array : ");
      for(int i = 0; i < array2.length; i++){
        array2[i= Integer.parseInt(in.readLine());
      }
    }
    catch(NumberFormatException ne){
      ne.printStackTrace();
    }

    boolean check = Arrays.equals(array1, array2);
    if(check == false)
      System.out.println("Arrays are not same.");
    else
      System.out.println("Both Arrays are same.");
  }
}

Download this example.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

nice site for student and devloper

Posted by umakanta p on Wednesday, 05.28.08 @ 14:36pm | #61267

Latest Searches:
how to retrieve values
action:scope=
how to print arraylist
how to use maps in jav
validating username an
selecting option value
bean :write excel she
Date Examples veloci
how to create a text f
jcombobox in java
velocity control ru
ant build tool
how to write hql in da
Linux Caixa Mé???é????
Write a program to acc
session jsp
chicken
set colours Jtree
retrive data from data
Aதà¯??தàÂ
jdbctemplate.execute
disable minimize butto
example of JFileChoos
HTML tags in JSP
core java Applets
post data from a servl
ั?à¹???ะà¸?ะà¸?à
set value to httpsessi
JMF
session getting time
Excel open java applic
application context in
decimals
Combattons la programm
save file name
java date compare exam
ejp
How to insert multiple
add two numbers in jav
breakаÐ?????аÐ????а
Combattons la programm
jsp bank examples
java.util.Calendar
Combattons la programm
struts1.2 html:select
getchars
json
axis 2
ะ�ะ�ะ�?�
Create table and inser
servlet exception hand
ejb2 Entity bean sampl
multiactioncontroller
insert query in hibern
login form using mysql
insert data to text fi
DateFormate in java
uml classes
write a swing applicat
add row, delete row an
?б?а?а?б?а??б?а
org.gjt.mm.mysql.Drive
HWPF
delete files
fibonacci
make runing java progr
break��?��?�
how to write hql in da
jdk-6u1-windows-i586-p
jsp:forward tag
Servlet Example To Dis
Write a program that i
how to write hql in da
Applet tutorial
Struts1.1 example down
Photoshop Drawing Pixe
session scope-manually
Insert Data into Datab
java display applet me
Directory
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.