im having a problem with making stack with array converted to linked list

so far this is my code ...

import java.util.*;
public class Nkakainis {
public static void main(String[] args){
 Stack <String> istak = new Stack<String>();
 String[] names = {"john", "mark", "peter"};
 List<String> list1 = Arrays.asList(names);

 System.out.println("pushed " + istak.push(list1));
 
 }
}

i dont have an idea on how to push those strings..how can i display john, mark, peter?
and how can i make other stack operations show on the output (i.e. pop(), peek(), search(), isEmpty())?


corrections are greatly appreciated ... i really need ur help badly :(

Recommended Answers

All 2 Replies

Feel the difference between the element of the set, and a set of elements

for (String inner : list1) {
            System.out.println("pushed " + istak.push(inner));
        }

thanks! :) I LOVE U SO MUCH U MADE MY DAY :))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.