I need to make a final string in a class and initialize it from within a method, i searched the internet some says its possible some say not!
i passed over this and in the accepted answer he stated that's possible from constructor said nothing about non-constructor methods
But, if you remove static, you are allowed to do this:
class A {
private final int x;
public A()
{
x = 5;
} }
in my case in Android i want to do this
public class MyActivity extends Activity
{
final String DOWNLOADS_FOLDER_PATH;
@Override
public void onCreate(Bundle savedInstanceState)
{ ....
DOWNLOADS_FOLDER_PATH=Environment.getExternalStorageDirectory().getPath()+"/downloads/";
// i cant do that neither
// DOWNLOADS_FOLDER_PATH="s";
}
}
I need to initialize from a method because i have a call to
Environment.getExternalStorageDirectory().getPath()
any idea?