package Algorithmus;

public class Allgemeine_Übungen {

	public static void main(String[] args) {
		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];
	}

}
