EnumsAndAPIs

This commit is contained in:
2024-10-05 18:05:18 +02:00
parent c9e96af0a5
commit 819baf55d1
4 changed files with 32 additions and 0 deletions

View File

@ -3,6 +3,11 @@ package com.example;
import java.util.Scanner;
public class Main {
enum Rank {
SOLDIER,
SERGEANT,
CAPTAIN
}
public static void main(String[] args) {
System.out.println("Hello world!");
@ -37,5 +42,32 @@ public class Main {
};
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.
}
}