2013-07-06 51 views
0

我已經在SimpleCustomerService file.I創建包SimpleCustomer,並用它已經產生的.class文件SimpleCustomer哪裏,當我編譯SimpleCustomerService文件,它給出的錯誤。我解決不了我的error.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; 
} 
} 

我的錯誤是: EXP的非法啓動ression:公共的ArrayList getAllCustomers() 錯誤2:錯誤;例外:公共的ArrayList getAllCustomers()

第一誤差是在公共和第二誤差是在getALlCustomers()

預先感謝。

回答

3

它似乎你在你的主要方法,這是我相信導致錯誤嵌入的方法:

public static void main(String args[]) 
{ 
    ArrayList<SimpleCustomer> getAllCustomers() 
    { 

不知道爲什麼你想這樣做,但它是不允許的。你應該將你的getAllCustomers方法移出主要方法,看看它是否有幫助!

+0

我都試過,之前只有當我提出我的方法OUTOFF的main()是giveing錯誤包不列入存在 – user2083041

+0

@ user2083041ü可以將你的方法主要方法外,共享更新的代碼 –

+0

我已經上傳我的SimpleCustomerService代碼我得到相同的錯誤包無法找到 – user2083041