EnumsAndAPIs
This commit is contained in:
@ -3,6 +3,11 @@ package com.example;
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
enum Rank {
|
||||||
|
SOLDIER,
|
||||||
|
SERGEANT,
|
||||||
|
CAPTAIN
|
||||||
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("Hello world!");
|
System.out.println("Hello world!");
|
||||||
|
|
||||||
@ -37,5 +42,32 @@ public class Main {
|
|||||||
};
|
};
|
||||||
|
|
||||||
c.makesound();
|
c.makesound();
|
||||||
|
|
||||||
|
//ENUMS
|
||||||
|
|
||||||
|
Rank aa = Rank.SOLDIER;
|
||||||
|
|
||||||
|
switch(aa) {
|
||||||
|
case SOLDIER:
|
||||||
|
System.out.println("Soldier says hi!");
|
||||||
|
break;
|
||||||
|
case SERGEANT:
|
||||||
|
System.out.println("Sergeant says Hello!");
|
||||||
|
break;
|
||||||
|
case CAPTAIN:
|
||||||
|
System.out.println("Captain says Welcome!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Java API
|
||||||
|
// The Java API is a collection of classes and interfaces that have been written for you to use.
|
||||||
|
|
||||||
|
// The Java API Documentation with all of the available APIs can be located on the Oracle website at
|
||||||
|
|
||||||
|
// http://docs.oracle.com/javase/7/docs/api/
|
||||||
|
|
||||||
|
// Once you locate the package you want to use, you need to import it into your code.
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
BIN
castingandothers/target/classes/com/example/Main$Rank.class
Normal file
BIN
castingandothers/target/classes/com/example/Main$Rank.class
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user