+ 4
Unsetting variables
How can I unset any variables in Java such that I can reuse by using different type next time? For example : String a = "String" System.out.print(a); __________//block of code to unset variable 'a' int a = 5 System.out.print(a); I meant just like we use function "unset($variable)" in PHP. Please answer soon !
4 Answers
+ 6
you cant, as variable a is assigned to data type String. you can convert a string to int using Interger.parseInt(yourString); but the value of your string would have to be "5" and not "five" also you would have to use a new variable
String str = "5";
int a = Integer.parseInt(str);
System.out.print(a);
+ 1
I also don't know
+ 1
Dont
0
May be easy to do it so?
String strA = "string";
Int intA = Integer.parseInt(strA);
Or you need String a = null;
Start garbage collection, and after try to new a. Idk can be or dont, try...