嗨,我正在尝试让我的代码创建我需要创建手机对象的新构造函数对象,我尝试命名构造函数字段来创建对象,但是错误出现在
public Mobile(String Mobilephonetype, String Mobilescreensize,
String Mobilememorycardcapacity, String Mobilecameraresolution,
String MobileGPS), at the bottom of the page
为什么我会收到此错误?
java error, cannot find symbol - variable samsung
更新我已经将一些顶级字段从私有 int 更改为字符串,但现在它说找不到符号 - 类字符串,这是什么意思?
代码:
/**
* to write a simple java class Mobile that models a mobile phone.
*
* @author ()
* @version (14/10/13)
*/
public class Mobile
{
// type of phone
private string phonetype;
// size of screen in inches
private int screensize;
// menory card capacity
private int memorycardcapacity;
// name of present service provider
private string 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 string GPS;
// instance variables - replace the example below with your own
private int x;
// The constructor method
public Mobile(String mobilePhoneType, int mobileScreenSize,
int mobileMemoryCardCapacity, String newserviceprovider, int mobileCameraResolution,
String mobileGPS) {
this.phonetype = mobilePhoneType;
this.screensize = mobileScreenSize;
this.memorycardcapacity = mobileMemoryCardCapacity;
this.cameraresolution = mobileCameraResolution;
this.GPS = mobileGPS;
// you do not use this ones during instantiation,you can remove them if you do not need or assign them some default values
this.serviceprovider = newserviceprovider;
this.typeofcontract = 12;
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);
System.out.println("serviceprovider: " + serviceprovider);
System.out.println("typeofcontract: " + typeofcontract);
}
public Mobile(String MobilephoneType, int Mobilescreensize, int Mobilememorycardcapacity, String newserviceprovider, int Mobilecameraresolution,
String MobileGPS) {
this.phonetype = Mobilephonetype;
this.screensize = 3;
this.memorycardcapacity = 4;
this.cameraresolution = 8;
this.GPS = GPS;
this.serviceprovider = newserviceprovider;
this.typeofcontract = 12;
this.checkcharge = checkcharge;
}
}
class mymobile {
public static void main(String[] args) {
Mobile Samsung = new Mobile("Samsung", "3", "4", "8",
"GPS");
Mobile Blackberry = new Mobile("Blackberry", "3.", "4",
"8", "GPS");
Samsung.displayMobileDetails();
Blackberry.displayMobileDetails();
}
}