2013-01-31 8 views
0

Независимо от того, где я размещаю выходной оператор, будь то для 1-го места массива, всего массива или даже переменной счетчика. Я не могу распечатать НИЧЕГО на консоли. Я пробовал печать в основном и в функциях. есть идеи?ничего не выйдет

Редактировать 1: Я обнаружил, что могу печатать внутри окна jswing, но до сих пор не повезло с консолью, что затрудняет проверку ошибок.

Учитывая тот факт, что я могу по-прежнему корректно выводится в окне, и люди утверждают, затмение будет распечатать его, я посчитал, что консоль для моего древнего текстового редактора просто некомпетентны, я ценю помощь '

//=========================// 
//colby moniz project 9-1 // 
//Number sorter   // 
//=========================// 

//===========================================// 
//This program takes 10 integers and sorts // 
//them into even, odd, and negative.   // 
//===========================================// 

//=============// 
//Import Files // 
//=============// 
import javax.swing.*;  // DRAW DIALOG BOX CLASS 
import java.awt.*;   // IMPORT AWT TO CHANGE FONT AND COLORS 




public class p91 { 


    public static void main(String[] args) { 


     //=================================// 
     //varbiles section     // 
     //=================================// 
     sorter sort = new sorter(); //Creatests an instances of sorter, inside main. 
     int[] test = new int[10]; 
     int inputNum; 

     //================================// 
     //Introduction windows   // 
     //================================//  
     info("This program will sort 10 intergers, \n into the catagories minimum, maximum and negitive", 
     "Introduction"); 
     //===========================// 
     //fill up array    // 
     //===========================// 
     for(int count = 0; count < 10; count++) 
     { 
      inputNum = input("please input number " + (count + 1), "Input"); 
      test[count] = inputNum; 
     } 




     for(int count = 0; count < 10; count++) 
     { 
      System.out.print(test[count]);  
     } 


    } 





//====================================================// 
//Functions           // 
//====================================================//  


     public static void info(String a, String b) 
    { 
      //================================// 
      //Introduction window    // 
      //================================// 
      int close = JOptionPane.showConfirmDialog(null, 
           a, b,          
           JOptionPane.DEFAULT_OPTION, 
           JOptionPane.INFORMATION_MESSAGE); 

      checkCloseInt(close); 
    } 

     public static void checkCloseInt(int close) 
    { 
      //===================================== 
      //checks to see if user closed program 
      //=====================================     
      if ((close == JOptionPane.CLOSED_OPTION) || 
       (close == JOptionPane.NO_OPTION) || 
       (close == JOptionPane.CANCEL_OPTION))   
       System.exit(0);  
    } 

     public static int input(String a, String b) 
    { 
      //================================// 
      //input       // 
      //================================// 
      boolean parsable; 
      int inputParse = 999; 
      String input; 

      do 
      {   
        input = JOptionPane.showInputDialog(null, 
             a, b,          
             JOptionPane.QUESTION_MESSAGE); 

        //======================// 
        //Check if close  // 
        //======================// 
         if(input == null) 
         { 
          System.exit(0); 
         } 

        parsable = error(input); 

      } 
      while(parsable == false); 

     inputParse = Integer.parseInt(input); 
        System.out.print(inputParse); 
     return inputParse; 
    } 



    public static boolean error(String input) 
    { 
     //====================== 
     //Check if parsable 
     //======================= 
     boolean parsable = true; 
      try 
      { 
      int inputParse = Integer.parseInt(input); 
      } 
      catch(NumberFormatException e) 
      { 
      parsable = false; 
      } 

      if(parsable == false) 
      { 
        errorWindow("Please input a number"); 
      } 

      return parsable; 



    } 

     public static void errorWindow(String a) 
    { 
      //================================// 
      //Introduction window    // 
      //================================// 
      int close = JOptionPane.showConfirmDialog(null, 
           a, "Error",          
           JOptionPane.DEFAULT_OPTION, 
           JOptionPane.ERROR_MESSAGE); 

      checkCloseInt(close); 
    } 




} 

'

+0

Я выполнил ваш код в Eclipse. После ввода 10 номеров я проверил консоль и вот они! 10 цифр, как ранее было введено! Не говоря уже и о результате выполнения 'System.out.print (inputParse)' ... Вам необходимо предоставить более подробную информацию ... – GeorgeVremescu

+0

[Здесь] (http://www.jcreator.com/forums/ index.php? showtopic = 1620) – GeorgeVremescu

ответ

0

Использование System.out.println(); это работает для me'.

+2

'Log.e (String, String)' применим только в android не простое приложение java –

+0

sry, началось прямо с android, но thx, теперь я его знаю. – Ekonion

+0

Я попробовал println, ничего не произошло. Если это помогает, после каждого окна ввода оно мерцает, прежде чем перейти к следующему. – user1809295

Смежные вопросы