Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Theorical question about declaration/definition in java

Squall867Jun 10 2010 — edited Jun 11 2010
Hi, we know the difference between declaration and definition:
-declaration: no memory is allocated.
-definition: memory is allocated.

In C/C++ if we want to define a variable we can make
 int x;
or
int x = 5;
(we assign a value too)

while, if we just want to declare we can make
extern int x;
Is there a way in java to simply declare a variable? According to me just arrays can be declared with
String[] arrayString;
while istructions like
String myString;
are definition as they allocate at least a String reference on the stack...am I wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 9 2010
Added on Jun 10 2010
19 comments
594 views