Hallo, ich soll ein Programm schreiben, der mir die Position von einem bestimmten Buchstaben anzeigt, jedoch habe ich irgendwo einen Denkfehler..
Würde mich auf Hilfe sehr freuen..
class MZKett
{
static int [] buPos(String x, char bu)
{
int l=x.length();
char c[]=x.toCharArray();
for (int i=0; i<l ;i++ )
{
if (c (i) ==bu) {
return (i);
} // end of if
} // end of for
}
class MZKettAnw08
{
public static void main(String args[])
{
String x= "Hippopotomonstrosesquippedaliophobie";
char bu= 'o';
int Pos= MZKett.buPos(x, bu);
System.out.println(Pos);
}
}
Würde mich auf Hilfe sehr freuen..
class MZKett
{
static int [] buPos(String x, char bu)
{
int l=x.length();
char c[]=x.toCharArray();
for (int i=0; i<l ;i++ )
{
if (c (i) ==bu) {
return (i);
} // end of if
} // end of for
}
class MZKettAnw08
{
public static void main(String args[])
{
String x= "Hippopotomonstrosesquippedaliophobie";
char bu= 'o';
int Pos= MZKett.buPos(x, bu);
System.out.println(Pos);
}
}