我收到了错误 [英] I'm getting the error

查看:70
本文介绍了我收到了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(编译错误Main.java:69:错误:找不到符号shipmentEntity [k] .display(); ^符号:方法display()location:class ShipmentEntity 1 error)以下程序..



我尝试过:



(Compilation Errors Main.java:69: error: cannot find symbol shipmentEntity[k].display(); ^ symbol: method display() location: class ShipmentEntity 1 error) for the below program..

What I have tried:

ShipmentEntity.java
  public class ShipmentEntity {
protected String shipmentEntityName;
protected String identificationNumber;
ShipmentEntity()
{
    
}

public ShipmentEntity(String shipmentEntityName, String identificationNumber) {
    super();
    this.shipmentEntityName = shipmentEntityName;
	this.identificationNumber = identificationNumber;
}
public String getShipmentEntityName() {
	return shipmentEntityName;
}
public void setShipmentEntityName(String shipmentEntityName) {
	this.shipmentEntityName = shipmentEntityName;
}
public String getIdentificationNumber() {
	return identificationNumber;
}
public void setIdentificationNumber(String identificationNumber) {
	this.identificationNumber = identificationNumber;
}





}





import java.io. *;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java .util.Date;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

公共类Main {



public static void main(String args [])抛出IOException,ParseException

{$ / $
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

System.out.println(输入装运实体数量);

int n = Integer.parseInt(buf.readLine());

int arrcusvalue = 0;

int arrcomvalue = 0;

int arragnvalue = 0;

int arrcarvalue = 0;

客户[]客户=新客户[n];

int cuslength = 0;

int comlength = 0;

int carrlength = 0;

int agnlength = 0;

公司[]公司=新公司[n];

承运人[]承运人=新承运人[n];

Agent [] agent = new Agent [n];

for(int i = 0;我< n; i ++)

{



System.out.println(输入货件实体+(i + 1)+详细信息: );

System.out.println(选择货运实体类型);

System.out.println(1)客户);

System.out.println(2)Company);

System.out.println(3)Agent);

System.out。 println(4)Carrier);

int enttype = Integer.parseInt(buf.readLine());



if(enttype == 1)

{

String [] val = buf.readLine()。split(,);

int invalue = Integer.parseInt(val [2]);

customer [cuslength ++] = Customer.createRecord(val [0],val [1],invalue,val [3]);

arrcusvalue = arrcusvalue + 1;

}

if(enttype == 2)

{

String [] val = buf.readLine()。split(,);

company [comlength ++] = Company.createRecord(val [0],val [1],val [2], VAL [3],VAL [4]); <无线电通信/>
arrcomvalue = arrcomvalue + 1;

}

if(enttype == 3)

{

String [] val = buf.readLine()。split(,);

agent [agnlength ++] = Agent.createRecord(val [0],val [1],val [ 2],val [3],val [4]);

arragnvalue = arragnvalue + 1;

}

if(enttype == 4)

{

String [] val = buf.readLine()。split(,);

carrier [carrlength ++] = Carrier.createRecord(val [0],val [1],val [2],val [3]);

arrcarvalue = arrcarvalue + 1;

}

}

System.out.println(货件详情为);

System.out.println(输入要显示的货件实体类型);

String entitytype;



entitytype = buf.readLine();

if(entitytype。 equals(Customer))

{

System.out.format(% - 15s%-25s%-15s%-15s \ n,名称,识别麻木呃,客户ID,客户名称);

for(int i = 0; i< arrcusvalue; i ++)

{



customer [i] .display();

}



}



if(entitytype.equals(Agent))

{

System.out.format(% - 15s% -25s%-15s%-15s%-15s \ n,名称,标识号,代理名称,IATA,FMC);

for(int i = 0; i< arragnvalue; i ++)

{



agent [i] .display();

}



}

if(entitytype.equals(Company))

{

System.out.format(% - 15s%-25s%-15s%-15s%-15s \ n,名称,标识号,公司名称,IATA ,FMC);

for(int i = 0; i< arrcomvalue; i ++)

{



company [i] .display();

}



}



if(entitytype.equals(Carrier))

{

System.out.format(% - 15s%-25s%-15s%-15s \ n,名称,标识号,代码名称, IATA);

for(int i = 0; i< arrcarvalue; i ++)

{



carrier [i] .display();

}



}





}

}



import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

public static void main(String args[]) throws IOException, ParseException
{
BufferedReader buf= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of shipment entity");
int n = Integer.parseInt(buf.readLine());
int arrcusvalue=0;
int arrcomvalue=0;
int arragnvalue=0;
int arrcarvalue=0;
Customer[] customer=new Customer[n];
int cuslength=0;
int comlength=0;
int carrlength=0;
int agnlength=0;
Company[] company=new Company[n];
Carrier[] carrier=new Carrier[n];
Agent[] agent=new Agent[n];
for (int i = 0; i <n; i++)
{

System.out.println("Enter the shipment entity "+(i+1)+" details :");
System.out.println("Select the shipment entity type");
System.out.println("1)Customer");
System.out.println("2)Company");
System.out.println("3)Agent");
System.out.println("4)Carrier");
int enttype = Integer.parseInt(buf.readLine());

if (enttype==1)
{
String[] val = buf.readLine().split(",");
int invalue=Integer.parseInt(val[2]);
customer[cuslength++]=Customer.createRecord(val[0],val[1],invalue,val[3]);
arrcusvalue=arrcusvalue+1;
}
if (enttype==2)
{
String[] val = buf.readLine().split(",");
company[comlength++] = Company.createRecord(val[0],val[1],val[2],val[3],val[4]);
arrcomvalue=arrcomvalue+1;
}
if (enttype==3)
{
String[] val = buf.readLine().split(",");
agent[agnlength++]=Agent.createRecord(val[0],val[1],val[2],val[3],val[4]);
arragnvalue=arragnvalue+1;
}
if (enttype==4)
{
String[] val = buf.readLine().split(",");
carrier[carrlength++]=Carrier.createRecord(val[0],val[1],val[2],val[3]);
arrcarvalue=arrcarvalue+1;
}
}
System.out.println("Shipment details are");
System.out.println("Enter the shipment entity type to display");
String entitytype;

entitytype=buf.readLine();
if (entitytype.equals("Customer"))
{
System.out.format("%-15s %-25s %-15s %-15s\n","Name","Identification Number","Customer Id","Customer Name");
for(int i=0;i<arrcusvalue;i++)
{

customer[i].display();
}

}

if (entitytype.equals("Agent"))
{
System.out.format("%-15s %-25s %-15s %-15s %-15s\n","Name","Identification Number ","Agent Name","IATA","FMC");
for(int i=0;i<arragnvalue;i++)
{

agent[i].display();
}

}
if (entitytype.equals("Company"))
{
System.out.format("%-15s %-25s %-15s %-15s %-15s\n","Name","Identification Number","Company Name","IATA","FMC");
for(int i=0;i<arrcomvalue;i++)
{

company[i].display();
}

}

if (entitytype.equals("Carrier"))
{
System.out.format("%-15s %-25s %-15s %-15s\n","Name","Identification Number","Code Name","IATA");
for(int i=0;i<arrcarvalue;i++)
{

carrier[i].display();
}

}


}
}

推荐答案

Quote:

(编译错误Main.java:69:错误:找不到符号shipmentEntity [k] .display(); ^符号:方法display()location:class ShipmentEntity 1 error)以下程序..

(Compilation Errors Main.java:69: error: cannot find symbol shipmentEntity[k].display(); ^ symbol: method display() location: class ShipmentEntity 1 error) for the below program..



你的代码确实有一个


Your code does have a

shipmentEntity[k].display();







我们不能如果您没有提供正确的信息,请帮助您。


at all.

We can't help you if you don't give correct information.


这是船舶实体



This is Ship Entity

ShipmentEntity.java
  public class ShipmentEntity {
protected String shipmentEntityName;
protected String identificationNumber;
ShipmentEntity()
{
    
}

public ShipmentEntity(String shipmentEntityName, String identificationNumber) {
    super();
    this.shipmentEntityName = shipmentEntityName;
	this.identificationNumber = identificationNumber;
}
public String getShipmentEntityName() {
	return shipmentEntityName;
}
public void setShipmentEntityName(String shipmentEntityName) {
	this.shipmentEntityName = shipmentEntityName;
}
public String getIdentificationNumber() {
	return identificationNumber;
}
public void setIdentificationNumber(String identificationNumber) {
	this.identificationNumber = identificationNumber;
}





}


这篇关于我收到了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆