3:44 pm - Wednesday December 11, 3540

Stack Example Program for toString()

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  toString()
**/
import java.io.*;
import java.util.*;
public class StackToString
{
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
String st = s.toString(); // Returns a string representation of this stack
System.out.println("Elements of the String are: ");
System.out.println(st);
}
}

OUTPUT:
Elements of the String are:
[A, B, C,D, E, F, G]

BACK

Filed in: Z-A All Java Codes

Comments are closed.