Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Caleb Smith   on Feb 09 In Java Category.

  
Question Answered By: Julia Flores   on Feb 09

What I think you are saying is that you want to dynamically create a
variable at runtime of type int and maybe even give it a value. You can not
extend the members of a class or method at runtime like that, however if you
need to assign a value to a variable and you don't know the type until the
program is running then assign it an object to start with and at runtime
convert the object to the appropriate datatype on the fly.

//Design time Example.

Object unknownType = null;

//Runtime example:

int = ((Integer) unknownType).intValue;

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on how to execute a statement Or get search suggestion and latest updates.


Tagged: