Java-new Operators and [ ] operator / Chapter -11/Operator & Assignments

           
 

   new Operator:-

1. "new operator" is used to create objects.It allocates the memory to object.

example:-

Test     t    = new    Test ( );

2. After creating an object constructor will be executed to perform initialization of objects.

Hence constructor is not meant  for object creation , it is meant for initialization of objects.


3.In java, there is only "new" keyword for allocating the memory but not "delete" keyword because the destruction of the useless object (to clean or free the memory) is the responsibility of Garbage Collector.






                                               [ ] Operator:-

This Operator is used for declaring and creating the Arrays.

example  1:-


int    [  ]    a = new   int [ 10 ];

example  2:-


int    [  ]    x = new   int [ 20 ];



Next:Chapter -12/Operator & Assignments / Operator Precedence
Back:Chapter -10/Operator & Assignments / Conditional  Operators
                                              Home:

No comments:

Post a Comment

Be the first to comment!

Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.

Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.

Regards,
JavaByChetan
Back To Home

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com