高手指点啊 关于数组的调用问题
import java.io.*;
class lianlian
{
int i=0;
int num[];
public void set(int count)
{
String str;
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
for( i=0;i<=count-1;i++)
{
System.out.print("请输入第"+(i+1)+"个学生的成绩:");
try {
str=buf.readLine();
num[i]=Float.parseFloat(str);
}
catch (
NumberFormatException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
catch (
IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}finally {}
}
}
public void shuchu(int count){
for( i=0;i<= count-1;i++)
{
System.out.println(+num[i]);
}
}
class mm
{
public static void main(String[] args) throws IOException
{
lianlian num = new lianlian();
num.set(4);
num.shuchu(4);
}
}
怎么调试不过啊 高手指点啊
------解决方案--------------------package test;
import java.io.*;
class lianlian {
int i = 0;
int[] num = new int[10];
public void set(int count) {
String str;
BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
for (i = 0; i <= count - 1; i++) {
System.out.print("请输入第" + (i + 1) + "个学生的成绩:");
try {
str = buf.readLine();
num[i] = Integer.parseInt(str);
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void shuchu(int count) {
for (i = 0; i <= count - 1; i++) {
System.out.println(i + "的成绩为:" + num[i]);
}
}
}
public class MM {
public static void main(String[] args) {
lianlian num = new lianlian();
num.set(4);
num.shuchu(4);
}
}
------解决方案--------------------import java.io.BufferedReader;
import
java.io.IOException;
import java.io.InputStreamReader;
class lianlian
{
private static double num[]=new double[100];
public static void set(int count)
{
String str;
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i <=count-1;i++)
{
System.out.print("请输入第"+(i+1)+"个学生的成绩:");
try {
str=buf.readLine();
num[i]=java.lang.Double.parseDouble(str);
}
catch (NumberFormatException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}finally
{
}
}
}
public void shuchu(int count){
for(int i=0;i<count;i++)
{
System.out.println(+num[i]);
}
}
}
class mm
{
public static void main(String[] args)
{
lianlian num = new lianlian();
num.set(4);
num.shuchu(4);
}
}