主函數package com.imocc;public class Initailtelephone {?? ?public static void main(String[] args) {?? ??? ?// TODO Auto-generated method stub????? // telephone phone=new telephone();?????? telephone phone2=new telephone(5.0f,1.4f,2.0f);?? ?}}構造方法public telephone(float newscreen,float newcpu,float newmem){?? ??? if(newscreen<3.5){?? ??? ??? System.out.println("您輸入的參數有問題,自動賦值3.5");?? ??? ??? screen=3.5f;?? ??? }?? ??? else{?? ??? screen=newscreen;?? ??? }?? ??? cpu=newcpu;?? ??? mem=newmem;?? ??? System.out.println("有參的構造的方法執行了");?? }}
添加回答
舉報
0/150
提交
取消