Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 没有输出_Java_Arrays_Printing_For Loop_Output - Fatal编程技术网

Java 没有输出

Java 没有输出,java,arrays,printing,for-loop,output,Java,Arrays,Printing,For Loop,Output,无论我将输出语句放在何处,它都是数组的1个位置、数组的所有位置,甚至是count变量。我无法将任何内容打印到控制台。我试过在主界面和功能界面上打印。有什么想法吗 Edit1:我发现我可以在jswing窗口中打印,但控制台仍然不走运,这使得错误检查变得困难。 考虑到我仍然可以在窗口中正确输出,并且有人声称eclipse将打印出来,我认为我的古代文本编辑器的控制台不称职,我感谢您的帮助 " //=========================// //科尔比·莫尼兹项目9-1// //号码分拣机/

无论我将输出语句放在何处,它都是数组的1个位置、数组的所有位置,甚至是count变量。我无法将任何内容打印到控制台。我试过在主界面和功能界面上打印。有什么想法吗

Edit1:我发现我可以在jswing窗口中打印,但控制台仍然不走运,这使得错误检查变得困难。

考虑到我仍然可以在窗口中正确输出,并且有人声称eclipse将打印出来,我认为我的古代文本编辑器的控制台不称职,我感谢您的帮助 "

//=========================//
//科尔比·莫尼兹项目9-1//
//号码分拣机//
//=========================//
//===========================================//
//这个程序接受10个整数并进行排序//
//将它们分为偶数、奇数和负数//
//===========================================//
//=============//
//导入文件//
//=============//
导入javax.swing.*;//绘制对话框类
导入java.awt.*;//导入AWT以更改字体和颜色
公共类p91{
公共静态void main(字符串[]args){
//=================================//
//瓦比尔斯区//
//=================================//
sorter sort=new sorter();//在main内部创建一个sorter实例。
int[]测试=新的int[10];
int-inputNum;
//================================//
//介绍窗口//
//================================//    
信息(“此程序将10个整数分为最小、最大和负三类”,
“导言”);
//===========================//
//填充数组//
//===========================//
对于(int count=0;count<10;count++)
{
inputNum=输入(“请输入数字”+(计数+1),“输入”);
测试[计数]=输入数;
}   
对于(int count=0;count<10;count++)
{
系统输出打印(测试[计数]);
}
}
//====================================================//
//功能//
//====================================================//    
公共静态无效信息(字符串a、字符串b)
{
//================================//
//介绍窗口//
//================================//
int close=JOptionPane.showConfirmDialog(null,
a、 b,,
JOptionPane.DEFAULT_选项,
JOptionPane.INFORMATION(信息和消息);
checkCloseInt(关闭);
}
公共静态无效检查关闭int(int关闭)
{
//=====================================
//检查用户是否关闭了程序
//=====================================                 
if((close==JOptionPane.CLOSED_选项)|
(close==JOptionPane.NO_选项)||
(close==JOptionPane.CANCEL_选项)
系统出口(0);
}
公共静态int输入(字符串a、字符串b)
{
//================================//
//输入//
//================================//
布尔可分解;
int inputParse=999;
字符串输入;
做
{           
input=JOptionPane.showInputDialog(null,
a、 b,,
JOptionPane.QUESTION_消息);
//======================//
//检查是否关闭//
//======================//
如果(输入==null)
{
系统出口(0);
}
parsable=错误(输入);
}
while(parsable==false);
inputParse=Integer.parseInt(输入);
系统输出打印(输入解析);
返回inputParse;
}
公共静态布尔错误(字符串输入)
{
//======================
//检查是否可行
//=======================
布尔可分解=真;
尝试
{ 
int-inputParse=Integer.parseInt(输入);
}
捕获(数字格式)
{
parsable=false;
} 
if(parsable==false)
{
errorWindow(“请输入一个数字”);
} 
返回可解析;
}
公共静态无效错误窗口(字符串a)
{
//================================//
//介绍窗口//
//================================//
int close=JOptionPane.showConfirmDialog(null,
a、 “错误”,
JOptionPane.DEFAULT_选项,
JOptionPane.ERROR\u消息);
checkCloseInt(关闭);
}
}

使用
System.out.println()
这对我很有用。

Log.e(String,String)
只适用于android,不是一个简单的java应用程序。我尝试了println,什么都没发生。如果有帮助的话,在每个输入窗口之后,它会在进入下一个窗口之前闪烁。我在Eclipse中执行了您的代码。在输入10个数字后,我检查了控制台,它们就在那里!之前输入的10个数字!更不用说执行
System.out.print(inputParse)
的结果了。。。你需要提供更多的细节。。。
//=========================//
//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); 
    }




}