|
1 | 1 | public class Main { |
2 | 2 |
|
| 3 | + /* |
| 4 | + * 1. Datentypen |
| 5 | + * 2. Keywords, Access Types |
| 6 | + * 3. Methods |
| 7 | + * */ |
| 8 | + |
| 9 | + /* |
| 10 | + <--[ Variablen Typen ]--> |
| 11 | + */ |
| 12 | + short myShort = 2; |
| 13 | + static int myInt = 123; |
| 14 | + long myLong = 123123123123l; |
| 15 | + |
| 16 | + float myFloat = 1.3456f; |
| 17 | + double myDouble = 1.2346; |
| 18 | + |
| 19 | + String myString = "Hey! This is my string!"; |
| 20 | + |
| 21 | + /* |
| 22 | + <--[ Arrays ]--> |
| 23 | + */ |
| 24 | + float myFloatArray[] = {1, 2, 3, 1.3456f}; |
| 25 | + String myStringArray[] = {"hey!", "ho!"}; |
| 26 | + int myIntArray; |
| 27 | + |
| 28 | + /* |
| 29 | + <--[ Methoden / Getter & Setter ]--> |
| 30 | + */ |
| 31 | + |
| 32 | + private static int myPrivateInt; |
| 33 | + |
| 34 | + public static int getMyPrivateInt() { |
| 35 | + return myPrivateInt; |
| 36 | + } |
| 37 | + |
| 38 | + public static void setMyPrivateInt(int setter) { |
| 39 | + myPrivateInt = setter; |
| 40 | + } |
| 41 | + |
| 42 | + |
| 43 | + public int myPublicInt; |
| 44 | + |
| 45 | + /* |
| 46 | + <--[ Access Type: 'final' ]--> |
| 47 | + */ |
| 48 | + |
| 49 | + private static final String MYSTATICFINASTRING = "Hey ho"; |
| 50 | + |
| 51 | + |
| 52 | + /* |
| 53 | + Static Voids |
| 54 | + */ |
| 55 | + |
| 56 | + public static void hello(String name, String secondname) { |
| 57 | + System.out.println("Hello, " + name + " and " + secondname); |
| 58 | + } |
| 59 | + |
3 | 60 | public static void main(String[] args) { |
4 | | - System.out.println("Hello World!"); |
5 | | - System.out.print("This is my first Java Program!"); |
| 61 | + // System.out.println("Hello World!"); |
| 62 | + // System.out.print("This is my first Java Program!"); |
| 63 | + |
| 64 | + hello("Ringo", "Martin"); |
| 65 | + |
| 66 | + // MYSTATICFINASTRING = "asd"; -> ERROR |
| 67 | + |
| 68 | + System.out.println(Integer.toString(myInt)); |
| 69 | + |
| 70 | + setMyPrivateInt(17); |
| 71 | + |
| 72 | + System.out.println(getMyPrivateInt()); |
| 73 | + |
| 74 | + int myNewInt = getMyPrivateInt(); |
6 | 75 | } |
7 | 76 |
|
8 | 77 | } |
| 78 | + |
0 commit comments