Hallo,
ich bin gerade neu hinzugekommen und muss gleich eine (für mich) wichtige Frage loswerden. Ich "lerne" Java mit einem Buch vom Markt und Technik Verlag ("Jetzt lerne ich Java") und bin auf ein Problem gestoßen. In dem Unterkapitel zur formatierten Ausgabe mit printf() der Klasse Console, bin ich leider stecken geblieben.
Das Eclipse führt folgendes Programm nicht aus, das ich, da es ein Beispiel aus dem Buch ist, einmal abtippen wollte:
Diese Fehlermeldung wird nach dem Kompilieren angezeigt:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method printf(String, Object[]) in the type Console is not applicable for the arguments (String)
The method printf(String, Object[]) in the type Console is not applicable for the arguments (String, String, double)
The method printf(String, Object[]) in the type Console is not applicable for the arguments (String, String, double)
at testfiles.CBildschirmausgabe.main(CBildschirmausgabe.java:6)
Es scheint ja irgendeine Exception ausgelöst zu werden. Verwende ich System.console.printf() nicht richtig (habe in der API gestöbert und da stand etwas in der Art der Fehlermeldung, was ich aber nicht verstanden habe).
Ich würde mich sehr freuen, wenn mir jemand bei meinem Problem helfen könnte.
Gruß Mojo Jojo http://www.java-forum.org/images/smilies/confused.gif
ich bin gerade neu hinzugekommen und muss gleich eine (für mich) wichtige Frage loswerden. Ich "lerne" Java mit einem Buch vom Markt und Technik Verlag ("Jetzt lerne ich Java") und bin auf ein Problem gestoßen. In dem Unterkapitel zur formatierten Ausgabe mit printf() der Klasse Console, bin ich leider stecken geblieben.
Das Eclipse führt folgendes Programm nicht aus, das ich, da es ein Beispiel aus dem Buch ist, einmal abtippen wollte:
Java:
package basics;
import java.io.Console;
public class CBildschirmausgabe {
public static void main(String[] args) {
Console cons = System.console();
cons.printf("\n");
String ware = "Heft";
double preis = 1.75;
cons.printf(" 1 %10s kostet %.2f Euro \n", ware, preis);
ware = "Füller";
preis = 0.55;
cons.printf(" 1 %10s kostet %.2f Euro \n", ware, preis);
}
}
Diese Fehlermeldung wird nach dem Kompilieren angezeigt:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method printf(String, Object[]) in the type Console is not applicable for the arguments (String)
The method printf(String, Object[]) in the type Console is not applicable for the arguments (String, String, double)
The method printf(String, Object[]) in the type Console is not applicable for the arguments (String, String, double)
at testfiles.CBildschirmausgabe.main(CBildschirmausgabe.java:6)
Es scheint ja irgendeine Exception ausgelöst zu werden. Verwende ich System.console.printf() nicht richtig (habe in der API gestöbert und da stand etwas in der Art der Fehlermeldung, was ich aber nicht verstanden habe).
Ich würde mich sehr freuen, wenn mir jemand bei meinem Problem helfen könnte.
Gruß Mojo Jojo http://www.java-forum.org/images/smilies/confused.gif