Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Foo {
- ...
- public static final int BAR;
- public static final int BAZ;
- public static final int BAM;
- ...
- }
- public static String lookup(int constant) {
- switch (constant) {
- case Foo.BAR: return "bar";
- case Foo.BAZ: return "baz";
- case Foo.BAM: return "bam";
- default: return "unknown";
- }
- }
- public abstract class Foo {
- ...
- public static final int BAR=0;
- public static final int BAZ=1;
- public static final int BAM=2;
- ...
- }
- public static final int BAR = new Random().nextInt();
- public class MainClass {
- enum Choice { Choice1, Choice2, Choice3 }
- public static void main(String[] args) {
- Choice ch = Choice.Choice1;
- switch(ch) {
- case Choice1:
- System.out.println("Choice1 selected");
- break;
- case Choice2:
- System.out.println("Choice2 selected");
- break;
- case Choice3:
- System.out.println("Choice3 selected");
- break;
- }
- }
- }
- public static final int TAKE_PICTURE = 1;
- public static int TAKE_PICTURE = 1;
- public enum Foo
- {
- BAR("bar"),
- BAZ("baz"),
- BAM("bam");
- private final String description;
- private Foo(String description)
- {
- this.description = description;
- }
- public String getDescription()
- {
- return description;
- }
- }
- System.out.println(Foo.BAR.getDescription());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement