Git
parent
73eab43f6a
commit
d5dd1528b7
|
@ -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);
|
||||
}
|
||||
String text = "H";
|
||||
try {
|
||||
System.out.println(codePointBefore(text,1));
|
||||
|
||||
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;
|
||||
}catch(StringIndexOutOfBoundsException e) {
|
||||
System.out.println(e.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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.
|
@ -5,7 +5,7 @@ import java.util.Random;
|
|||
public class GamePlay {
|
||||
|
||||
public static void main(String[] args) {
|
||||
GameWindow game = new GameWindow();
|
||||
new GameWindow();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue