Guest User

Untitled

a guest
Jan 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public enum DaysOfweek
  2. {
  3. SUNDAY,MONDAY.....
  4. }
  5.  
  6. public final class MyClass {
  7. private MyClass() { }
  8. }
  9.  
  10. public final class MyClass {
  11. public static string MY_STRING;
  12. public static int MY_INT;
  13.  
  14. private MyClass() {}
  15. }
  16.  
  17. public final class MyClass {
  18.  
  19. private MyClass() {
  20. // Private so noone else can instantiate this
  21. }
  22.  
  23. }
  24.  
  25. public final class A {
  26. public static final int YOUR_CONST = 5;
  27.  
  28. }
  29.  
  30. public final class A {
  31. public static final int YOUR_CONST = 5;
  32.  
  33. private A() {}
  34.  
  35. }
  36.  
  37. public final class Trial // it is the FINAL
  38. {
  39. private static final int CONSTANT_VALUE = 666;
  40.  
  41. private Trial() // it is PRIVATE instead of PUBLIC
  42. {
  43. }
  44.  
  45. public static int getConstantValue()
  46. {
  47. return CONSTANT_VALUE;
  48. }
  49. }
  50.  
  51. public class Bully //extends Trial ////"extends" WILL NOT COMPILE
  52. {
  53. public static void main(String[] args)
  54. {
  55. //Trial trial = new Trial(); ////"new Trial()" WILL NOT COMPILE
  56.  
  57. // The only thing can be done is getting a constant value from "Trial"
  58. int acquiredValue = Trial.getConstantValue();
  59. System.out.println(acquiredValue);
  60. }
  61. }
Add Comment
Please, Sign In to add comment