N. Liraj N. Liraj - 1 year ago 82
Java Question

Initialization of a File object

I want to ask you about the format of initialization in java.

What I know in the moment is:

int a = 1;
double a = 1.0;
String a= "java";


Now, in the class main I want to initialize a
, and I don't know how to do this?

Answer Source

Firstly, a file is an object type, unlike int and double, which are primitive types. I am not sure how familiar you are with java, but to create an object you use the constructor for that object.

File has a constructor which receives a string of the location of that file on the computer.

File f = new File("path\\to\\your\\file");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download