Hi,

On 20 Feb., 08:23, benftima <[email protected]> wrote:
> pls can you help me to ad a main method for this class to run
> thanks , it always ask me main method does not exist
>
> Stack s = new Stack();
> s.push("Fred");
> s.push("John");
> s.push("Andrew");
> s.push("Xavier");
> s.push("Mark");
> s.push("Cameron");
>
> System.out.print("Size of stack: ");
> System.out.println(s.size());
>
> System.out.print("Checking the top to get the element without
> removing: ");
> System.out.println(s.peek());
>
> System.out.print("Search for Andrew: ");
> System.out.println(s.search("Andrew"));
>
> System.out.println("Printing elements using POP method: ");
> while (!s.empty()) {
> System.out.println(s.pop());
>
> }
>
>
This are statements which belong into a method.
You have to define a java class with the method

public static void main( String[] args ) {
}

In the main-Method you can put your code-statements from above.

The main-Method of the class which you give to the java execution will
be called.

HTH
Ewald

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to