by using constructors for example:
class MyInputStream {
private InputStream inputStream;
public InputStream getInputStream() {
return inputStream;
}
MyInputStream(String filename) throws FileNotFoundException {
inputStream = new FileInputStream(filename);
}
by using parameterized methods directly to get return value. for example:
public InputStream getInputStream(String filename) throws FileNotFoundException {
InputStream inputStream;
inputStream = new FileInputStream(filename);
return inputStream;
}
by using getter setter without constructor
class MyInputStream {
private InputStream inputStream;
public InputStream getInputStream() {
return inputStream;
}
...
...
}
or any other good professional time and resource saving dynamic universal good practice
Aucun commentaire:
Enregistrer un commentaire