BASE-4502: Update examples
This commit is contained in:
@@ -16,6 +16,5 @@ public class ClassConstants {
|
||||
public static final List<String> contributorGroups = Arrays.asList("contributor", "author");
|
||||
|
||||
public static final int MAXIMUM_NUMBER_OF_GUESTS = MAXIMUM_NUMBER_OF_USERS * 10;
|
||||
public static boolean DEFAULT_GROUPS_DEFINED = DEFAULT_GROUPS != null;
|
||||
|
||||
}
|
||||
@@ -4,14 +4,18 @@ import java.io.PrintWriter;
|
||||
|
||||
public class CompileTimeVariables {
|
||||
|
||||
public String ERROR_MESSAGE = ClassConstants.DEFAULT_USERNAME + " not allowed here.";
|
||||
public final int MAXIMUM_LOGIN_ATTEMPTS = 5;
|
||||
|
||||
public static void main(String[] args) {
|
||||
PrintWriter printWriter = System.console().writer();
|
||||
printWriter.write(ClassConstants.DEFAULT_USERNAME);
|
||||
|
||||
CompileTimeVariables instance = new CompileTimeVariables();
|
||||
printWriter.println(instance.MAXIMUM_LOGIN_ATTEMPTS);
|
||||
|
||||
final String username = "baeldung";
|
||||
printWriter.println(username);
|
||||
printWriter.println(instance.MAXIMUM_LOGIN_ATTEMPTS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ public class RunTimeVariables {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Console console = System.console();
|
||||
|
||||
final String input = console.readLine();
|
||||
console.writer().write(input);
|
||||
|
||||
final double random = Math.random();
|
||||
console.writer().write("Number: " + random);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.compiletimeconstants;
|
||||
|
||||
public class SwitchStatement {
|
||||
|
||||
private static final String VALUE_ONE = "value-one";
|
||||
|
||||
public static void main(String[] args) {
|
||||
final String valueTwo = "value" + "-" + "two";
|
||||
switch (args[0]) {
|
||||
case VALUE_ONE:
|
||||
break;
|
||||
case valueTwo:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user