新手JAVA 程序,大家帮我看看我这程序错在哪了
packagecom;importjava.io.*;publicclassMain{BufferedReaderbr=newBufferedReader(newInpu...
package com;
import java.io.*;
public class Main {
BufferedReader br=new BufferedReader(new InputSteamReader(System.in));
IdVO all[]=new IdVO[3];
void start()
{
try
{
for(int i=0;i<all.length;i++)
{
IdVO aIdVO()=new IdVO();
System.out.println("请输入姓名:");
aIdVO.setName(br.readLine());
System.out.println("请输入年龄:");
aIdVO.setAge(Integer.parseInt(br.readLine()));
System.out.println("请输入性别:");
aIdVO.setSex(Integer.parseInt(br.readLine()));
System.out.println("请输入学号:");
aIdVO.setId(br.readLine());
all[i]=aIdVO;
}
for(int i=0;i<all.length;i++)
{
System.out.println("姓名"+aIdVO.getName(i+1)+"年龄"+aIdVO.getAge(i+1)+"性别"+aIdVO.getName(i+1)+"学号"+aIdVO.getName(i+1)) ;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
new Main().start();
}
}
-----------------------------------------------------------------
package com;
class IdVO {
private String name;
private int age;
private String sex;
private int id;
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return (this.name);
}
public int getAge() {
return (this.age);
}
public String getSex() {
return (this.sex);
}
public int getId() {
return (this.id);
}
}
哪位大侠能帮我修改下
修改了下Main.java,但是还是不行
import java.io.*;
public class Main {
BufferedReader br=new BufferedReader(new InputSteamReader(System.in));//显示出错
IdVO all[]=new IdVO[3];
void start()
{
try
{
for(int i=0;i<all.length;i++)
{
IdVO aIdVO=new IdVO();
System.out.println("请输入姓名:");
aIdVO.setName(br.readLine());
System.out.println("请输入年龄:");
aIdVO.setAge(Integer.parseInt(br.readLine()));
System.out.println("请输入性别:");
aIdVO.setSex(br.readLine());
System.out.println("请输入学号:");
aIdVO.setId(Integer.parseInt(br.readLine()));
all[i]=aIdVO;
}
for(int i=0;i<all.length;i++)
{
System.out.println("姓名"+aIdVO.getName(i)) ; //这里怎么写,没弄明白
}
}
catch(Exception e)
{
e.printStackTrace();
}
} 展开
import java.io.*;
public class Main {
BufferedReader br=new BufferedReader(new InputSteamReader(System.in));
IdVO all[]=new IdVO[3];
void start()
{
try
{
for(int i=0;i<all.length;i++)
{
IdVO aIdVO()=new IdVO();
System.out.println("请输入姓名:");
aIdVO.setName(br.readLine());
System.out.println("请输入年龄:");
aIdVO.setAge(Integer.parseInt(br.readLine()));
System.out.println("请输入性别:");
aIdVO.setSex(Integer.parseInt(br.readLine()));
System.out.println("请输入学号:");
aIdVO.setId(br.readLine());
all[i]=aIdVO;
}
for(int i=0;i<all.length;i++)
{
System.out.println("姓名"+aIdVO.getName(i+1)+"年龄"+aIdVO.getAge(i+1)+"性别"+aIdVO.getName(i+1)+"学号"+aIdVO.getName(i+1)) ;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
new Main().start();
}
}
-----------------------------------------------------------------
package com;
class IdVO {
private String name;
private int age;
private String sex;
private int id;
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return (this.name);
}
public int getAge() {
return (this.age);
}
public String getSex() {
return (this.sex);
}
public int getId() {
return (this.id);
}
}
哪位大侠能帮我修改下
修改了下Main.java,但是还是不行
import java.io.*;
public class Main {
BufferedReader br=new BufferedReader(new InputSteamReader(System.in));//显示出错
IdVO all[]=new IdVO[3];
void start()
{
try
{
for(int i=0;i<all.length;i++)
{
IdVO aIdVO=new IdVO();
System.out.println("请输入姓名:");
aIdVO.setName(br.readLine());
System.out.println("请输入年龄:");
aIdVO.setAge(Integer.parseInt(br.readLine()));
System.out.println("请输入性别:");
aIdVO.setSex(br.readLine());
System.out.println("请输入学号:");
aIdVO.setId(Integer.parseInt(br.readLine()));
all[i]=aIdVO;
}
for(int i=0;i<all.length;i++)
{
System.out.println("姓名"+aIdVO.getName(i)) ; //这里怎么写,没弄明白
}
}
catch(Exception e)
{
e.printStackTrace();
}
} 展开
1个回答
展开全部
1.InputStreamReader 你少个r
2.IdVO aIdVO()=new IdVO(); 改为IdVO aIdVO=new IdVO(); 去掉对象名后的两个括号
3.System.out.println("请输入年龄:");
aIdVO.setAge(Integer.parseInt(br.readLine()));
System.out.println("请输入性别:");
aIdVO.setSex(br.readLine());
年龄是整数 性别是字符串
4.System.out.println("姓名"+all[i].getName()+"年龄"+all[i].getAge()+"性别"+all[i].getName()+"学号"+all[i].getName()) ;
这是我修改后的代码 通过了
package com;
import java.io.*;
public class Main {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
IdVO all[]=new IdVO[3];
void start()
{
try
{
for(int i=0;i<all.length;i++)
{
IdVO aIdVO=new IdVO();
System.out.println("请输入姓名:");
aIdVO.setName(br.readLine());
System.out.println("请输入年龄:");
aIdVO.setAge(Integer.parseInt(br.readLine()));
System.out.println("请输入性别:");
aIdVO.setSex(br.readLine());
System.out.println("请输入学号:");
aIdVO.setId(Integer.parseInt(br.readLine()));
all[i]=aIdVO;
}
for(int i=0;i<all.length;i++)
{
System.out.println("姓名"+all[i].getName()+"年龄"+all[i].getAge()+"性别"+all[i].getName()+"学号"+all[i].getName()) ;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
new Main().start();
}
}
package com;
class IdVO {
private String name;
private int age;
private String sex;
private int id;
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return (this.name);
}
public int getAge() {
return (this.age);
}
public String getSex() {
return (this.sex);
}
public int getId() {
return (this.id);
}
}
2.IdVO aIdVO()=new IdVO(); 改为IdVO aIdVO=new IdVO(); 去掉对象名后的两个括号
3.System.out.println("请输入年龄:");
aIdVO.setAge(Integer.parseInt(br.readLine()));
System.out.println("请输入性别:");
aIdVO.setSex(br.readLine());
年龄是整数 性别是字符串
4.System.out.println("姓名"+all[i].getName()+"年龄"+all[i].getAge()+"性别"+all[i].getName()+"学号"+all[i].getName()) ;
这是我修改后的代码 通过了
package com;
import java.io.*;
public class Main {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
IdVO all[]=new IdVO[3];
void start()
{
try
{
for(int i=0;i<all.length;i++)
{
IdVO aIdVO=new IdVO();
System.out.println("请输入姓名:");
aIdVO.setName(br.readLine());
System.out.println("请输入年龄:");
aIdVO.setAge(Integer.parseInt(br.readLine()));
System.out.println("请输入性别:");
aIdVO.setSex(br.readLine());
System.out.println("请输入学号:");
aIdVO.setId(Integer.parseInt(br.readLine()));
all[i]=aIdVO;
}
for(int i=0;i<all.length;i++)
{
System.out.println("姓名"+all[i].getName()+"年龄"+all[i].getAge()+"性别"+all[i].getName()+"学号"+all[i].getName()) ;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
new Main().start();
}
}
package com;
class IdVO {
private String name;
private int age;
private String sex;
private int id;
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return (this.name);
}
public int getAge() {
return (this.age);
}
public String getSex() {
return (this.sex);
}
public int getId() {
return (this.id);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询