ITPub博客

首页 > 应用开发 > > java中定义的溢出,求大大help,45行抛出的异常。

java中定义的溢出,求大大help,45行抛出的异常。

作者:wghdd 时间:2019-10-17 15:06:08 0 删除 编辑

package com.immoc;

public class Imooc {

   float screen=4.7f;

   float mem=16.0f;

   float cpu=2.0f;

   int var2=5;

  public void call(){

  System.out.println("it`s able to call");

  int var2=3;

  System.out.println(var2);

  

  }

   public void message(){

 System.out.println("mem:"+mem);

 System.out.println("cpu:"+cpu);

       

     

   }

   public Imooc(){

  //nothing

   }

   public Imooc(float newScreen, float newCpu,float newMem){

  if(newScreen>3.5&&newScreen<10){

  newScreen=screen; 

  }

  else{

  System.out.println("input is worng");

  }

  if(newCpu>1.0&&newCpu<7){

  newCpu=cpu; 

  }else{

  System.out.println("input is worng");

  }

  if(newMem>2&&newMem<50){

  newMem=mem;

  }else{

  System.out.println("input is worng");

  }

  System.out.println("this function was done");

  System.out.println("this screen is "+newScreen);

  System.out.println("this cpu is "+newCpu);

  System.out.println("this mem is "+newMem);

   }

   Imooc imooc2=new Imooc();

  public static void main(String []args){

 

  

   Imooc imooc=new Imooc(4.7f,2.0f,16f);

  imooc.call();

  imooc.cpu=16.3f;

  imooc.mem=999.3f;

  imooc.message();

    }

}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1775/viewspace-3167195/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    109
  • 访问量
    864