7:05 am - Thursday December 13, 2018

Stack Example Program for equals(Object o)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*@author :CandidJava.com
*@descriptions : This program explain the function and use of equals(Object o)
*/
import java.io.*;
import java.util.*;
public class StackEquals
{
public static void main(String arg[])throws Exception
{
Stack s=new Stack();//to create object for Stack class
s.add("a");//to add an element in Stack
s.add("b");//to add an element in Stack
s.add("c");//to add an element in Stack
s.add("d");//to add an element in Stack
s.add("e");//to add an element in Stack
s.add("f");//to add an element in Stack
s.add("g");//to add an element in Stack
Stack s1=new Stack();//to create object for another Stack class
s1.add("a");//to add an element in Stack
s1.add("b");//to add an element in Stack
s1.add("c");//to add an element in Stack
s1.add("d");//to add an element in Stack
s1.add("e");//to add an element in Stack
s1.add("f");//to add an element in Stack
s1.add("g");//to add an element in Stack
boolean b=s.equals(s1); // Compares the specified Object with the Stack for equality
System.out.println(b);
}
}

OUTPUT:
true

BACK

Filed in: Z-A All Java Codes

Comments are closed.