主函数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
提交
取消