Users Pricing

forum

home / developersection / forums / create variable dynamically in java and what are data types of variable

Create variable dynamically in java and what are data types of variable

Allen Scott 2548 13 Nov 2014

As we know variables are of different data types, but which data type are their names of?
As it seems they are String, but if they are String then this should be allowed:

int i=6;

String [] arr+i;

...as we can add an int to a String.
So if these are not String then what are they?
And if we want to create variable names dynamically how can we create it? By dynamically I mean whenever the user clicks on a specific JComponent, a new variable is created, like:

int i=0;

//on first click

String str+i; ///str0

i++;

///on 2nd click

String str+i;   ////str1

///i++;

How can I do it?


Allen Scott

Other


1 Answers