【发布时间】:2014-05-01 11:57:40
【问题描述】:
我遇到了“从 int 到字节的可能有损转换”错误的问题,但我没有在我的代码中将整数转换为字节。
public static void main(String[] args) {
Notebook ntb = new Notebook("Acer","Aspire",15000.0f,20,"Intel Core I73632QM",4,2.2f,"GeForce GT720M",2,8,1000,15.6f,100,150,"DVD"); //<- error here
}
这里是笔记本类
package semestralka;
public class Notebook extends produkt.Produkt{
private String procesor;
private byte pocetJader;
private float frekvence;
private String GPU;
private byte pametGPU;
private byte operacniPamet;
private int pevnyDisk;
private float uhloprickaDispleje;
private int sirka;
private int vyska;
private String mechanika;
public Notebook(String vyrobce, String model, float cena, int pocet, String procesor, byte pocetJader, float frekvence, String GPU, byte pametGPU, byte operacniPamet, int pevnyDisk, float uhloprickaDispleje, int sirka, int vyska, String mechanika) {
this.vyrobce = vyrobce;
this.model = model;
this.cena = cena;
this.pocet = pocet;
this.procesor = procesor;
this.pocetJader = pocetJader;
this.frekvence = frekvence;
this.GPU = GPU;
this.pametGPU = pametGPU;
this.operacniPamet = operacniPamet;
this.pevnyDisk = pevnyDisk;
this.uhloprickaDispleje = uhloprickaDispleje;
this.sirka = sirka;
this.vyska = vyska;
this.mechanika = mechanika;
}
//getters
public String getProcesor() {
return procesor;
}
public byte getPocetJader() {
return pocetJader;
}
public String getGPU() {
return GPU;
}
public byte getPametGPU() {
return pametGPU;
}
public byte getOperacniPamet() {
return operacniPamet;
}
public int getPevnyDisk() {
return pevnyDisk;
}
public float getUhloprickaDispleje() {
return uhloprickaDispleje;
}
public int getSirka() {
return sirka;
}
public int getVyska() {
return vyska;
}
public String getMechanika() {
return mechanika;
}
}
我不知道为什么会收到此错误。任何人都可以帮助我吗?谢谢。
【问题讨论】:
标签: java