Я создал пакет SimpleCustomer и использовал его в файле SimpleCustomerService. Я создал файл .class для SimpleCustomer, где, как когда я компилирую файл SimpleCustomerService, ему даются ошибки. I не удалось решить мою ошибку. Я новичок в java. спасибо заранееОшибка компиляции при импорте методов пакета?
моего файл пакет:
package com.adobe.objects;
import java.util.Date;
public class SimpleCustomer
{
private int customerId;
private String customerName;
private String customerAddress;
private String customerType;
private Date entryModifiedDate;
public int getCustomerId()
{
return this.customerId;
}
public void setCustomerId(int customerId) {
this.customerId = customerId;
}
public String getCustomerName() {
return this.customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getCustomerAddress() {
return this.customerAddress;
}
public void setCustomerAddress(String customerAddress) {
this.customerAddress = customerAddress;
}
public String getCustomerType() {
return this.customerType;
}
public void setCustomerType(String customerType) {
this.customerType = customerType;
}
public void setEntryModifiedDate(Date entryModifiedDate) {
this.entryModifiedDate = entryModifiedDate;
}
public Date getEntryModifiedDate() {
return this.entryModifiedDate;
}
}
и мой файл, который использует этот пакет:
package com.adobe.services;
import com.adobe.objects.SimpleCustomer;
import java.util.ArrayList;
import java.util.Date;
public class SimpleCustomerService
{
public static void main(String args[])
{
}
ArrayList<SimpleCustomer> getAllCustomers()
{
ArrayList customers = null;
try
{
int numberOfCustomers = 20;
SimpleCustomer customer = null;
customers = new ArrayList();
for (int loopCounter = 1; loopCounter <= numberOfCustomers; loopCounter++)
{
customer = new SimpleCustomer();
customer.setCustomerId(loopCounter);
customer.setCustomerName("Customer " + loopCounter);
customer.setCustomerType("Organization " + loopCounter);
customer.setCustomerAddress("Road # " + loopCounter + ", Bangalore, India");
customer.setEntryModifiedDate(new Date());
customers.add(customer);
}
}
catch (Exception e)
{
throw new RuntimeException(e);
}
return customers;
}
}
моей ошибка: незаконного начала ехра ression: открытая ArrayList getAllCustomers() ошибки 2: ошибка; за исключением: открытая ArrayList getAllCustomers()
первая ошибка в общественной и второй ошибки в getALlCustomers()
спасибо заранее.
Я пробовал это раньше, только когда я переместил свои методы outoff main(), он выдал ошибку, что пакет не существует – user2083041
@ user2083041 может уместить ваш метод вне основного метода и обмениваться обновленным кодом –
Я загрузил свой код SimpleCustomerService я получаю тот же пакет ошибок не могу найти – user2083041