1

I want to do something like this:

String[] name=new String[5];
String[] type=new String[5];
name[0]="variable";
type[0]="int";
name[0]=(type[0])(<any value to be assigned>);

The main issue I'm facing is typecasting like this.It says ';' expected after type[0].

Tarishi Jain
  • 254
  • 3
  • 13
  • you cannot convert any value to Integer like this and moreover, you are trying to store the Integer value in a string array – Shashank Gupta Jun 15 '19 at 08:36
  • @ShashankGupta please do no focus on the value part ,main part is to typecast when the datatype is stored in a variable – Tarishi Jain Jun 15 '19 at 08:42
  • Please go through this https://stackoverflow.com/questions/2127318/java-how-can-i-do-dynamic-casting-of-a-variable-from-one-type-to-another – Shashank Gupta Jun 15 '19 at 08:47

0 Answers0