Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum DaysOfweek
- {
- SUNDAY,MONDAY.....
- }
- public final class MyClass {
- private MyClass() { }
- }
- public final class MyClass {
- public static string MY_STRING;
- public static int MY_INT;
- private MyClass() {}
- }
- public final class MyClass {
- private MyClass() {
- // Private so noone else can instantiate this
- }
- }
- public final class A {
- public static final int YOUR_CONST = 5;
- }
- public final class A {
- public static final int YOUR_CONST = 5;
- private A() {}
- }
- public final class Trial // it is the FINAL
- {
- private static final int CONSTANT_VALUE = 666;
- private Trial() // it is PRIVATE instead of PUBLIC
- {
- }
- public static int getConstantValue()
- {
- return CONSTANT_VALUE;
- }
- }
- public class Bully //extends Trial ////"extends" WILL NOT COMPILE
- {
- public static void main(String[] args)
- {
- //Trial trial = new Trial(); ////"new Trial()" WILL NOT COMPILE
- // The only thing can be done is getting a constant value from "Trial"
- int acquiredValue = Trial.getConstantValue();
- System.out.println(acquiredValue);
- }
- }
Add Comment
Please, Sign In to add comment