嗨,我正在尝试让我的代码创建我需要的两个新的构造函数对象
为什么我会收到这个错误?,java 错误,Class Mobile 已经在包 unnamed 包中定义
错误出现在页面底部的公共课堂移动端
更新 我刚刚将第二个公共课程重命名为 mymobile 而不是 mobile,并将主要的公共课程保留为 Mobile(因为我正在做作业,它说第一个公共课程必须命名为 public class mobile),但是我现在收到此错误:Mobile 类中的构造函数 Mobile 不能应用于给定类型。
/**
* to write a simple java class Mobile that models a mobile phone.
*
* @author (ME)
* @version (14/10/13)
*/
public class Mobile
{
// type of phone
private int phonetype;
// size of screen in inches
private int screensize;
// menory card capacity
private int memorycardcapacity;
// name of present service provider
private int serviceprovider;
// type of contract with service provider
private int typeofcontract;
// camera resolution in megapixels
private int cameraresolution;
// the percentage of charge left on the phone
private int checkcharge;
// wether the phone has GPS or not
private int GPS;
// instance variables - replace the example below with your own
private int x;
// The constructor method
public Mobile (String Mobilephonetype, String Mobilescreensize, String Mobilememorycardcapacity, String Mobilecameraresolution, String MobileGPS, String Mobileserviceprovider, String Mobiletypeofcontract, String Mobilecheckcharge)
{
this.phonetype = phonetype;
this.screensize = screensize;
this.memorycardcapacity = memorycardcapacity;
this.cameraresolution = cameraresolution;
this.GPS = GPS;
this.serviceprovider = serviceprovider;
this.typeofcontract = typeofcontract;
this.checkcharge = checkcharge;
}
// The new constructor method
{
this.phonetype = phonetype;
this.screensize = screensize;
this.memorycardcapacity = memorycardcapacity;
this.cameraresolution = cameraresolution;
this.GPS = GPS;
this.serviceprovider = serviceprovider;
this.typeofcontract = typeofcontract;
this.checkcharge = checkcharge;
}
// A method to display the state of the object to the screen
public void displayMobileDetails()
{
System.out.println("phonetype: " + phonetype);
System.out.println("screensize: " + screensize);
System.out.println("memorycardcapacity: " + memorycardcapacity);
System.out.println("cameraresolution: " + cameraresolution);
System.out.println("GPS: " + GPS);
}
public class myMobile {
public static void main(String[] args) {
Mobile Samsung = new Mobile("Samsung", "3.0", "4gb", "8mega pixels","GPS" );
Mobile Blackberry = new Mobile("Blackberry", "3.0", "4gb", "8mega pixels","GPS" );
Samsung.displayMobileDetails();
Blackberry.displayMobileDetails();
}
}
}
any replies/answers would be greatly appreciated, thanks