-2

I just wanna know what does Object S[] mean in this code? This is a snippet of a source code for Stack in array. Is this a data type? What does it return? and what type of data should be entered?

public class ArrayStack implements Stack {

public static final int CAPACITY = 1000;
public int capacity;
Object S[];
Mark Asnee
  • 17
  • 4

2 Answers2

0

In answer to the titular question Object S[]; is a declaration of an array of objects named S.

What does it return?

Nothing. What does what return? You have given the start of a class's definition, so without closing it throws an error.

If you mean, "What does Object S[]; return", again, nothing is returned because it is not an operation. https://www.freecodecamp.org/news/when-to-use-a-function-declarations-vs-a-function-expression-70f15152a0a0/

Please try and break your question down next time as each one is based on an increasingly fuzzy understanding of the answers to those it follows.

John
  • 6,433
  • 7
  • 47
  • 82
0

Object S[]; is just a variable declaration. The variable is called S and has type Object[]. You could also write it as Object[] S; for clarity.

It doesn't "return" anything, but S is an uninitialized array of Object. After initializing you can add any object to it.

QBrute
  • 4,405
  • 6
  • 34
  • 40