Topic: 求助,关于数组 |
Print this page |
1.求助,关于数组 | Copy to clipboard |
Posted by: 紫蝴蝶 Posted on: 2005-04-09 14:53 本人初学JAVA,诚盼高人指点,不胜感激 我按书上编的程序,编译通过,可是输出是乱码,麻烦诸位指教
|
2.Re:求助,关于数组 [Re: 紫蝴蝶] | Copy to clipboard |
Posted by: woaiyuan Posted on: 2005-04-12 15:38 编译出来有两个错误。。 a[i]=new Student(m,y); . . . {return num |
3.Re:求助,关于数组 [Re: 紫蝴蝶] | Copy to clipboard |
Posted by: undefined Posted on: 2005-04-14 09:04 import java.io.*; public class Ary { public static void main(String arg[]) { Student a[] = new Student[3]; int i, m = 0; String x = "undefined", y = "undefined"; for (i = 0; i < 3; i++) { System.out.println("输入学生信息"); try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); x = in.readLine(); m = Integer.parseInt; } catch (IOException e) {} try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); y = in.readLine(); } catch (IOException e) {} a[i] = new Student(m, y); } System.out.println(a.length); for (int ii = 0; ii < a.length; ii++) { System.out.println(a[ii].toString()); } } } class Student { private int id; private String name; Student(int m, String y) { id = m; name = y; } int getid() { return id; } String getnum() { return name; } public String toString() { String s; s = "学生信息: " + id +" "+ name; return s; } } |
4.Re:求助,关于数组 [Re: 紫蝴蝶] | Copy to clipboard |
Posted by: undefined Posted on: 2005-04-14 09:09 上面的代码输出结果 输入学生信息 111 zhang ming 输入学生信息 222 tom 输入学生信息 333 jack 3 学生信息: 111 zhang ming 学生信息: 222 tom 学生信息: 333 jack |
5.Re:求助,关于数组 [Re: 紫蝴蝶] | Copy to clipboard |
Posted by: VirusCamp Posted on: 2005-04-14 13:04 输出乱码? 是win9x下?linux下?没开中文显示吧?win9x下是命令行窗口上一个"汉"字.linux下?好像很复杂,不晓得. |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |