• Post Reply Bookmark Topic Watch Topic
  • New Topic

Explain the working of the following statement.  RSS feed

 
gauravkv gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi all,

i need to get some explaination on the following statement which i found in book "Thinking in Java".
static Test monitor = new Test();


Regards
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Please ShowSomeEffort. We have no idea what you know, what you are confused with, etc.

Henry
 
gauravkv gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Please ShowSomeEffort. We have no idea what you know, what you are confused with, etc.

Henry


i want to know is this possible to use both static and new in single statement, since new is for dynamic mem alloc and static is for compile stime mem alloc.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gauravkv gupta wrote:
Henry Wong wrote:
Please ShowSomeEffort. We have no idea what you know, what you are confused with, etc.

Henry


i want to know is this possible to use both static and new in single statement,


Then you can just write some code to try it and see if it works.

You can also do a web search.

You can also go through a tutorial or text from the beginning. After all, you're going to have to know the basics to write any Java code anyway, and once you know the basics, you'll know the answer to your question.

static is for compile stime mem alloc.


No it's not. The static keyword just means that the member or initializer in question pertains to the class as a whole, not to individual instances, and that it can be referenced without there being a "current" object, and that there's no this associated with it or available to it.

Also note that "compile time memory allocation" has no meaning in Java. There simply is no such thing.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you allocate memory at compile time? I could compile the code on my machine, email you the .jar file, and you could run it.

Surely you don't think that my compiling it would allocate memory on your device?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!