Moin,
ich bin Java- Anfänger (seit 1 Monat dabei) und habe ein Problem bei folgendem Code:
Wenn ich dieses Programm starten will, kommt ein Launch-Error: "Editor does not contain a main type". Da nichts aus dem Internet geholfen hat, wollte ich fragen, woran das liegt"🙂
(In der richtigen Klasse ist es gespeichert etc.)
ich bin Java- Anfänger (seit 1 Monat dabei) und habe ein Problem bei folgendem Code:
Code:
public class JavaIsAlwaysCallByValue {
public static void main (String[] args ) {
System.out.println( removeVowels1( "Fischers Fritze fischt frische Fische" ) );
System.out.println( removeVowels2( "Fischers Fritze fischt frische Fische" ) );
}
static String removeVowels1( String s ) {
char[] chars = new char[s.length()];
int len = 0;
for ( int i = 0; i < s.length(); i++ ) {
char c = s.charAt( i );
if ( "aeiouöäüyAEIOUÄÖÜY".indexOf( c ) < 0 )
chars[ len++ ] = c;
}
return new String( chars, 0, len );
}
private final static char[] VOWELS = { 'a', 'e', 'i', 'o', 'u', 'ä', 'ö', 'ü' };
static String removeVowels2( String s ) {
String newText = "";
for ( int i = 0; i < s.length(); i++ ) {
char c = s.charAt( i );
int pos = Arrays.binarySearch( VOWELS, Character.toLowerCase( c ) );
if ( pos < 0 )
newText = newText + c;
}
return newText;
}
}
Wenn ich dieses Programm starten will, kommt ein Launch-Error: "Editor does not contain a main type". Da nichts aus dem Internet geholfen hat, wollte ich fragen, woran das liegt"🙂
(In der richtigen Klasse ist es gespeichert etc.)