Guest User

Untitled

a guest
Jun 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. class MyClass {
  2. private final int counter;
  3. public MyClass(final int counter) {
  4. this.counter = counter;
  5. }
  6. }
  7.  
  8. class MyClass {
  9. private final int counter;
  10. public MyClass() {
  11. this(0);
  12. }
  13. public MyClass(final int counter) {
  14. this.counter = counter;
  15. }
  16. }
  17.  
  18. public class Deck {
  19. private final static List<String> SUITS;
  20.  
  21. static {
  22. List<String> list = new ArrayList<String>();
  23. list.add("Clubs");
  24. list.add("Spades");
  25. list.add("Hearts");
  26. list.add("Diamonds");
  27. SUITS = Collections.unmodifiableList(list);
  28. }
  29.  
  30. ...
  31. }
  32.  
  33. private final static List<String> SUITS =
  34. Collections.unmodifiableList(
  35. Arrays.asList("Clubs", "Spades", "Hearts", "Diamonds")
  36. );
  37.  
  38. public class MyClass {
  39.  
  40. static private Properties propTable;
  41.  
  42. static
  43. {
  44. try
  45. {
  46. propTable.load(new FileInputStream("/data/user.prop"));
  47. }
  48. catch (Exception e)
  49. {
  50. propTable.put("user", System.getProperty("user"));
  51. propTable.put("password", System.getProperty("password"));
  52. }
  53. }
  54.  
  55. public class MyClass
  56. {
  57. public MyClass()
  58. {
  59. synchronized (MyClass.class)
  60. {
  61. if (propTable == null)
  62. {
  63. try
  64. {
  65. propTable.load(new FileInputStream("/data/user.prop"));
  66. }
  67. catch (Exception e)
  68. {
  69. propTable.put("user", System.getProperty("user"));
  70. propTable.put("password", System.getProperty("password"));
  71. }
  72. }
  73. }
  74. }
Add Comment
Please, Sign In to add comment