请教一个关于编译程序的问题
我的代码:import java.io.*;
class Input
{
int i;
int [] array = new int[5];
BufferedReader br;
String [] s= new String[5];
public void init()
{
System.out.print("input the number: ");
for(i=0;i<=4;i++)
{
br=new BufferedReader(new InputStreamReader(System.in));
try
{
s[i]=br.readLine();
}
catch(IOException e)
{
e.printStackTrace();
}
array[i]=Integer.parseInt(s[i]);
}
}
}
public class dk
{
public static void main(String[] args)
{
Input input = new Input();
input.init();
int i,j,k;
int [] arr = new int[5];
for(i=0;i<=4;i++)
{
arr[i]=input.array[i];
}
for(j=0;j<5;j++)
for( k=j+1;k<5;k++)
{
if(arr[j]<arr[k])
{
int sum=0;
sum=arr[j];
arr[j]=arr[k];
arr[k]=sum;
} }
System.out.print("the order is: ");
for(i=0;i<=4;i++)
{
System.out.print(arr[i]+" ");
}
}
}这个程序在命令提示符下可以得出正确的结果,可是在eclipse中却会报错,出错在第一句,在最左边有个红色的叉叉 错误提示是:
Mutiple ers at this line,the type Input is already defined,76以更改 行
可是奇怪的是点击运行 程序居然可以运行 可是得不到正确的结果
我的代码:import java.io.*;
class Input
{
int i;
int [] array = new int[5];
BufferedReader br;
String [] s= new String[5];
public void init()
{
System.out.print("input the number: ");
for(i=0;i<=4;i++)
{
br=new BufferedReader(new InputStreamReader(System.in));
try
{
s[i]=br.readLine();
}
catch(IOException e)
{
e.printStackTrace();
}
array[i]=Integer.parseInt(s[i]);
}
}
}
public class dk
{
public static void main(String[] args)
{
Input input = new Input();
input.init();
int i,j,k;
int [] arr = new int[5];
for(i=0;i<=4;i++)
{
arr[i]=input.array[i];
}
for(j=0;j<5;j++)
for( k=j+1;k<5;k++)
{
if(arr[j]<arr[k])
{
int sum=0;
sum=arr[j];
arr[j]=arr[k];
arr[k]=sum;
} }
System.out.print("the order is: ");
for(i=0;i<=4;i++)
{
System.out.print(arr[i]+" ");
}
}
}这个程序在命令提示符下可以得出正确的结果,可是在eclipse中却会报错,出错在第一句,在最左边有个红色的叉叉 错误提示是:
Mutiple ers at this line,the type Input is already defined,76以更改 行
可是奇怪的是点击运行 程序居然可以运行 可是得不到正确的结果
难道是这些东西的问题????
这就奇怪了啊 我真怀疑我的eclipse哪里出问题了