小弟我按找你说的写了一个,可能没读明白你的意思,如果有什么不对,请指出: import java.math.*; import java.io.*; public class Test { public static void main(String[] args) { System.out.print("enter j:"); int j=MyInput.readInt(); double[] s; s=abc(j); printA(s); } static double[] abc(int i) { double[] s=new double[i]; for(int k=0;k<s.length;k++) {s[k]=(Math.random()*20); if(s[k]<10) s[k]=s[k]+10; } return s; } static void printA(double[] s) { for(int i=0;i<s.length;i++ ) System.out.println(s[i]); } }
class MyInput { static String readString() { BufferedReader br=new BufferedReader(new InputStreamReader(System.in),1); String string=" "; try { string=br.readLine(); } catch(IOException e) { System.out.println(e); } return string; } public static int readInt() { return Integer.parseInt(readString()); } }