Answer the question
In order to leave comments, you need to log in
What is the difference between creating an object in Java like this, or like this?
What is up, programmer.
StackOfStrings s;
s = new StackOfStrings(100);
StackOfStrings s = new StackOfStrings(100);
Answer the question
In order to leave comments, you need to log in
First case:
You declare a StackOfStrings variable named s, but don't initialize it
And only then do it on the second line
Second case:
You declare a StackOfStrings variable named s and initialize it right away
Essentially there is no difference, mostly it's the code design
StackOfStrings s;
System.out.print(s);
s = new StackOfStrings(100);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question