คำตอบที่ได้รับเลือกจากเจ้าของกระทู้
ความคิดเห็นที่ 5
// import com.sun.javafx.binding.StringFormatter;
// import com.sun.org.apache.xpath.internal.operations.String;
java.lang.String
อะไร ๆ ใน java.lang.*
เราใช้ได้เลย ไม่ต้อง import นะครับ
// import com.sun.org.apache.xpath.internal.operations.String;
java.lang.String
อะไร ๆ ใน java.lang.*
เราใช้ได้เลย ไม่ต้อง import นะครับ
▼ กำลังโหลดข้อมูล... ▼
แสดงความคิดเห็น
คุณสามารถแสดงความคิดเห็นกับกระทู้นี้ได้ด้วยการเข้าสู่ระบบ
เขียนโปรแกรม
ภาษา java ครับ
ทำไม ส่วนที่ return String.format คำว่าformat มันerror ครับ
นี่ codeครับ ตรงบรรทัดสุดท้ายครับ
import com.sun.javafx.binding.StringFormatter;
import com.sun.org.apache.xpath.internal.operations.String;
public class boxv2 {
private double w,h,d;
public boxv2(double w,double h,double d){
setW(w);
this.h = h;
this.d = d;
}
public boxv2(){
}
public double getW(){
return w;
}
public void setW(double w)
{
if (w > 0.0) {
this.w = w;
}else
{
throw new IllegalArgumentException("ค่าความกว้างจะต้องมากกว่าศูนย์");
}
}
public void setH(double h)
{
this.h = h;
}
public void setD(double d)
{
this.d = d;
}
public double vol()
{
return w*h*d;
}
public double sur(){
return (2.0*w*h)+(2.0*w*d)+(2.0*d*h);
}
@Override
public String toString(){
return String.format
}
}