Generic Stacks methods?

ISortableStack is an interface (it specifies the signatures of methods but not the code that goes in those methods) and thus it can't itself be instantiated. Instead try using your concrete implementation class.

ISortableStack s = new ISortableStack(5); //Cannot instatiate ISORTABLESTACK ISortableStack is an interface (it specifies the signatures of methods but not the code that goes in those methods) and thus it can't itself be instantiated. Instead try using your concrete implementation class: ISortableStack s = new SortableStack(); Now, E in SortableStack is a type parameter: it's a placeholder for some specific class, like String. Instead of specifying E as the user of this class, you need to tell the compiler what E should map to for this instance.It looks like your stack needs to hold characters, so what you really want is: ISortableStack s = new SortableStack(); char character; while ( (character = (char)System.in.read())!

= '\n') { //... s. Push(character); } You don't need ch to be a member of demo.

Beat me to it :) @Yonathan in addition to this you're going to have a problem because you don't have a constructor that takes in an int. – Shaded Aug 22 at 19:37 @Shaded: That's a good point, I'll change that now. – Mark Peters Aug 22 at 19:40 Im sure , I will .

Any suggestion to improving the code on that? – Yonathan Aug 22 at 19:44 +1 for explaining the answer with enough detail so the OP understands what is really wrong with the code posted in question. – Drupad Panchal Aug 22 at 19:45 Have I missed the SortableStack( int ) constructor?

– ZenMaster Aug 22 at 19:47.

At that specific line (ISortableStack s = new ISortableStack(5);) there are several things going on. Let's sort them out one by one: ISortableStack is a raw type. References to generic type ISortableStack should be parameterized the problem here is that you are trying to use raw type.

The next step would be to parametrize it: Cannot instantiate the type ISortableStack You are trying to create an instance of an interface - which is of course should fail. Use a class instead. Cannot make a static reference to the non-static type E Type parameters cannot be used in any static context, which your main method is.

Other than that - you seem to be missing parts of your code...

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions