我有这个教程,但我无法解决它。如果有更多的错误,请告诉我如何解决它,因为我是java的新手。这是我的代码:
import java.util.ArrayList;
import java.util.Collections;
public class Customer
{
public static void main(String args[]){
Arraylist listcustomer1 = new Arraylist();``
Arraylist listcustomer2 = new Arraylist();
Scanner scan = new Scanner(System.in);
customer a = new customer;
for(i=0;i<30;i++)
{
System.out.println("Enter customer name : ");
name = scan.next;
System.out.prinln("Enter customer id :" );
int custId= scan.nextInt;
System.out.println("Enter number of purchases :");
int numOfPurchases = scan.nextInt;
System.out.println("Enter the city :");
city = scan.next;
listcustomer1.add(i);
}
int total =0,avg = 0;
for(int i=0;i<listcustomer1.numOfPurchase;i++)
{
total= total+numOfPurchase;
avg = total/listcustomer1;
if(listcustomer1.numOfPurchase<10){
listcustomer1.remove(i);
Collections.copy(listcustomer2,i);
}
}
System.out.println("Customer Purchase Information ");
System.out.println("Total number of purchases from all cities " +total);
System.out.println("Average number of purchase from all cities " +avg);
}
}
我收到此错误错误customer.java:12:错误:(
或[
期待customer a = new customer;
有人可以解释一下吗?
答案 0 :(得分:1)
在此行中,客户a =新客户;您忘了写()
将其替换为Customer a = new Customer();
此外,您的班级名称为Customer
而非customer
。请记住,java是区分大小写的
答案 1 :(得分:0)
这不是有效的Java声明:
Customer a = new Customer; // Invalid
将其更改为:
Customer a = new Customer();