-8

Is it possible to have Java object dynamically? I am new in this language and curious too.

Edit: Apology, I think I posted the wrong word.

Thanks for any answer.

user221234
  • 27
  • 1
  • 6
  • 3
    As stated, the premise of this question seems to be incorrect. Objects do not exist at compile time. They are *only* created at runtime. – user2357112 Jul 24 '14 at 14:35
  • 1
    I think you either swapped the terms Runtime (when the program is _running_) vs. compile time (when you hit _build_ in your IDE) or have some huge misconception about what an object is. – AlexR Jul 24 '14 at 14:36
  • you need to read Herbert Schildt's Java book : http://books.google.be/books/about/Java.html?id=C_l2R8ZSPMoC&redir_esc=y and since you have just started learning, dont get discouraged by downvotes this happens to all of us at some point. This is how SO welcomes you :) – Sikorski Jul 24 '14 at 14:40
  • i don't know exactly,but is the OP asking to change its properties at run-time? – Deepanshu J bedi Jul 24 '14 at 14:44
  • @DeepanshuBedi edited my question. Sorry for typo. – user221234 Jul 24 '14 at 14:50
  • @SaumyaTiwari You should read some books and google your problems. – Deepanshu J bedi Jul 24 '14 at 14:50
  • [Refer this for your answer](http://stackoverflow.com/questions/13868986/dynamically-create-an-object-in-java-from-a-class-name-and-set-class-fields-by-u) – Deepanshu J bedi Jul 24 '14 at 14:54

3 Answers3

2

Objects in Java are only created at Runtime.

Deepanshu J bedi
  • 1,530
  • 1
  • 11
  • 23
1

Compilation phase is to translate human readable language that you use to code to byte code , which is understood by Java Virtual Machine, there's no object notion there.

Objects are created runtime by Java Virtual Machine based on classes that you create as a programmer.

Start here:

http://www.javabeginner.com/learn-java/java-classes-and-objects

alobodzk
  • 1,284
  • 2
  • 15
  • 27
0

Yes reflection can provide dynamic object creation(on fly )

Class anonymous = Class.forName("CLass name");
anonymous.getInstance();

All objects are created at Runtime in java.

Deepu--Java
  • 3,742
  • 3
  • 19
  • 30