master
3009594 2024-09-18 12:00:03 +02:00
parent 73eab43f6a
commit d5dd1528b7
4 changed files with 30 additions and 29 deletions

View File

@ -3,36 +3,37 @@ package Algorithmus;
public class Allgemeine_Übungen {
public static void main(String[] args) {
String text = "HalloWelt";
String o = "o";
text.substring(0, 0);
int x = indexof(text,o);
System.out.println(x);
}
public static int indexof(String text,String s) {
for (int i = 0; i < text.length(); i++)
if (text.charAt(i) == s.charAt(0))
return i;
return 0;
}
public static void find_Sub_Array(int[] arr, int target) {
int merker = 0;
for (int i = 0; i < arr.length -1 ; i++) {
merker = arr[i];
for (int j = i + 1; j < arr.length; j++) {
merker += arr[j];
if (merker == target) {
System.out.println("Ab Index: " + i + " bis Index: " + j + " sind die Summer der Zahl: " + target);
break;
}
}
String text = "H";
try {
System.out.println(codePointBefore(text,1));
}catch(StringIndexOutOfBoundsException e) {
System.out.println(e.toString());
}
}
static int codePointBefore(String s, int index)throws StringIndexOutOfBoundsException{
if (index > s.length() + 1 || index < 1)
throw new StringIndexOutOfBoundsException();
char[] charArray = s.toCharArray();
return charArray[index-1];
}
static int codePointAt(String s, int index)throws StringIndexOutOfBoundsException {
if (index > s.length() || index < 0)
throw new StringIndexOutOfBoundsException();
char[] charArray = s.toCharArray();
return charArray[index];
}
static char charAt(String s, int index) throws StringIndexOutOfBoundsException {
if (index > s.length() || index < 0)
throw new StringIndexOutOfBoundsException();
char[] charArray = s.toCharArray();
return charArray[index];
}
}

Binary file not shown.

Binary file not shown.

View File

@ -5,7 +5,7 @@ import java.util.Random;
public class GamePlay {
public static void main(String[] args) {
GameWindow game = new GameWindow();
new GameWindow();
}