#Java - Code Snippets for '#Final' - 4 code snippet(s) found |
|
Sample 1. Example of Factory Class | |
|
public final class EmployeeFactory {
private Employee svEmp;
public EmployeeFactory(String type){
if( type.equals("Manager")){
svEmp = new Manager();
} else if(type.equals("Developer")){
svEmp = new Developer();
} else if(type.equals("QA")){
svEmp = new QA();
}
}
public Employee getFactoryProduct() {
return svEmp;
}
}
|
|
Like Feedback factory design pattern factory class final class composition |
|
|
Sample 2. Exception handling and logging using Log4j | |
|
private static final Logger LOGGER = Logger.getLogger(BuggyBread.class);
public static void main(String[] args) {
try {
// Do Something
} catch (Throwable t) {
LOGGER.error("Shit Happens");
} finally {
// release the connections
}
}
|
|
Like Feedback exception handling exceptions log4j logging logger finally |
|
|
Sample 3. Declaring static final ( constant ) variables. | |
|
public abstract class TestClass {
protected static final String TEST_STRING = "test";
public static void main(String[] args){
}
}
|
|
Like Feedback static final variables constant variables |
|
|
Sample 4. Constant Class | |
|
public class Constants {
public static final long ZERO = 0L;
public static final long HUNDRED = 100L;
public static final long THOUSAND = 1000L;
}
|
|
Like Feedback constant class static final variable |
|
|