+ 1
How can i cast String to ObjectName
Hi Geeks I have 10 instances of class B, B b1 ,b2,b3,b4 etc ; i would like to excute them inside a loop : String s = "b"; B r ; int i = 0; while(i<10){ i++; r = (B) s + i;// i want to change thid valu to "B" class , but it didnt work with me , plz help if u can r.getClassName(); }
2 Réponses
+ 2
I assume an array of B instances was not an option?
+ 1
Can you share your code?
According to above code snippet, while loop is Infinite..
And to cast, both must be compatible each other....