Issue with using switch in Java

前端 未结 5 1751
谎友^
谎友^ 2021-01-23 16:22

I can\'t figure out why it\'s always returning the value of arg1. I\'m building a weight converter.

public double convert(double arg1,int arg2,int arg3) {
    //         


        
5条回答
  •  广开言路
    2021-01-23 16:53

    You are missing break statements:

    case 0: 
       answer = (arg1 * milligram) / milligram;
       break;
       ...
    

提交回复
热议问题