2016-10-31 7 views
-4

Ich habe ein Problem, wenn ich dies ausführen, es druckt einfach nichts. Ich bekomme keine Fehler und trotzdem druckt es nichts. Ich kann es nicht mal tippen. Was ist los, bitte helfen. Ich habe ein paar Tage daran gearbeitet, um die Fehler zu beheben, die es am Anfang und jetzt nach dem Reparieren gab, als ich es versuchte. Es sagt einfach nichts. Ich habe noch nie gesehen, das so bitte jemand mir helfenKonsole druckt nichts?

public class Mac { 

    public static void main(String[]args) { 

    } 

    public Mac() 
    { 
     intArrayExample(); 
     stringArrayExample(); 
     intArrayExample2(); 
     stringArrayExample(); 
    } 


    private void intArrayExample() 
    { 
     int[] intArray = new int[3]; 
     intArray[0] = 1; 
     intArray[1] = 2; 
     intArray[2] = 3; 
     System.out.println("Numerical Listing"); 
     for (int i=0; i<intArray.length; i++) 
     { 
      System.out.println(intArray[i]); 
     } 
    } 

    private void stringArrayExample() 
    { 
     String[] stringArray = new String[3]; 
     stringArray[0] = "a"; 
     stringArray[1] = "b"; 
     stringArray[2] = "c"; 
     System.out.println("Alphabetical Listing"); 
     for (int i=0; i<stringArray.length; i++) 
     { 
     System.out.println(stringArray[i]); 
     } 
    } 


    private void intArrayExample2() 
    { 
     int[] intArray = new int[] {4,5,6,7,8}; 
     System.out.println("Numerical Listing (version 2)"); 
     for (int i=0; i<intArray.length; i++) 
     { 
     System.out.println(intArray[i]); 
     } 
    } 

    @SuppressWarnings("unused") 
    private void stringArrayExample1() 
    { 
     String[] stringArray = new String[3]; 
     stringArray[0] = "d"; 
     stringArray[1] = "h"; 
     stringArray[2] = "e"; 
     stringArray[3] = "f"; 
     System.out.println("Alphabetical Listing (version 2)"); 
     for (int i=0; i<stringArray.length; i++) 
     { 
     System.out.println(stringArray[i]); 
     } 
    } 
} 
+0

Es ist nicht alles drucken, weil Ihre Hauptmethode ist leer. –

+1

Wie ist das ein [Tag: Compiler-Fehler]? – Kritner

+1

machen Sie alle Ihre Methoden 'statischen' Typ und rufen' Mac() 'von Ihrer' main' Methode auf – davedwards

Antwort

1

Ihre Hauptmethode public static void main(String[]args) ist leer! Nichts wird ausgeführt! Sie shoud Mac mac = new Mac();, dies zu tun schreiben, alle Methoden im Konstruktor rufen:

public Mac() 
{ 
    intArrayExample(); 
    stringArrayExample(); 
    intArrayExample2(); 
    stringArrayExample(); 
} 
Verwandte Themen